Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
EIT-SWE
ux
utils
Commits
418b706c
Commit
418b706c
authored
Feb 28, 2020
by
Shane Eckenrode
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filter to prevent cases of no and/or multiple fulfilled breakpoints
parent
3da56e3e
Pipeline
#85249
passed with stages
in 4 minutes and 5 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
12 deletions
+18
-12
libs/utils/responsive/src/lib/responsive.directive.ts
libs/utils/responsive/src/lib/responsive.directive.ts
+1
-1
libs/utils/responsive/src/lib/responsive.service.ts
libs/utils/responsive/src/lib/responsive.service.ts
+17
-11
No files found.
libs/utils/responsive/src/lib/responsive.directive.ts
View file @
418b706c
...
...
@@ -21,7 +21,7 @@ export class ResponsiveDirective implements OnInit, OnDestroy {
constructor
(
private
responsiveService
:
ResponsiveService
)
{}
ngOnInit
():
void
{
public
ngOnInit
():
void
{
this
.
responsiveService
.
currentScreenSize$
.
pipe
(
filter
(
size
=>
!!
size
),
...
...
libs/utils/responsive/src/lib/responsive.service.ts
View file @
418b706c
import
{
BreakpointObserver
}
from
'
@angular/cdk/layout
'
;
import
{
Injectable
,
OnDestroy
}
from
'
@angular/core
'
;
import
{
combineLatest
,
Observable
,
ReplaySubject
,
Subject
}
from
'
rxjs
'
;
import
{
map
,
takeUntil
,
tap
}
from
'
rxjs/operators
'
;
import
{
filter
,
map
,
takeUntil
,
tap
}
from
'
rxjs/operators
'
;
import
{
PSU_BREAKPOINTS
}
from
'
./breakpoints.model
'
;
import
{
ScreenSize
}
from
'
./screen-size.model
'
;
...
...
@@ -45,23 +45,29 @@ export class ResponsiveService implements OnDestroy {
combineLatest
(
this
.
isMobile$
,
this
.
isTabletSmall$
,
this
.
isTabletLarge$
,
this
.
isDesktop$
)
.
pipe
(
map
(([
mobile
,
tabletSmall
,
tabletLarge
,
desktop
])
=>
({
mobile
,
tabletSmall
,
tabletLarge
,
desktop
})),
filter
(
responsiveChange
=>
{
const
values
=
Object
.
values
(
responsiveChange
);
return
values
.
some
(
breakpoints
=>
!!
breakpoints
)
&&
values
.
filter
(
val
=>
!!
val
).
length
===
1
;
}),
tap
(
responsiveChange
=>
{
let
screenSize
:
ScreenSize
;
if
(
responsiveChange
.
mobile
)
{
screenSize
=
ScreenSize
.
MOBILE
;
this
.
isMobile
=
true
;
}
else
if
(
responsiveChange
.
tabletSmall
)
{
screenSize
=
ScreenSize
.
TABLET_SM
;
this
.
isTabletSmall
=
true
;
if
(
responsiveChange
.
desktop
)
{
screenSize
=
ScreenSize
.
DESKTOP
;
this
.
isDesktop
=
true
;
}
else
if
(
responsiveChange
.
tabletLarge
)
{
screenSize
=
ScreenSize
.
TABLET
;
this
.
isTabletLarge
=
true
;
}
else
{
screenSize
=
ScreenSize
.
DESKTOP
;
this
.
isDesktop
=
true
;
}
else
if
(
responsiveChange
.
tabletSmall
)
{
screenSize
=
ScreenSize
.
TABLET_SM
;
this
.
isTabletSmall
=
true
;
}
else
if
(
responsiveChange
.
mobile
)
{
screenSize
=
ScreenSize
.
MOBILE
;
this
.
isMobile
=
true
;
}
this
.
screenSizeChange
(
screenSize
);
if
(
!!
screenSize
)
{
this
.
screenSizeChange
(
screenSize
);
}
}),
takeUntil
(
this
.
_destroy$
)
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment