This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scroll$ = fromEvent(window, 'scroll').pipe( | |
throttleTime(10), | |
map(() => window.pageYOffset), | |
pairwise(), | |
map(([y1, y2]): Direction => (y2 < y1 ? Direction.Up : Direction.Down)), | |
distinctUntilChanged(), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum Direction { | |
Up = 'Up', | |
Down = 'Down' | |
} | |
const scroll$ = fromEvent(window, 'scroll').pipe( | |
throttleTime(10), | |
map(() => window.pageYOffset), | |
pairwise(), | |
map(([y1, y2]): Direction => (y2 < y1 ? Direction.Up : Direction.Down)), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const scroll$ = fromEvent(window, 'scroll').pipe( | |
throttleTime(10), | |
map(() => window.pageYOffset), | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-sticky-header', | |
template: `<ng-content></ng-content>`, | |
styles: [ | |
` | |
:host { | |
position: fixed; | |
top: 0; | |
width: 100%; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum VisibilityState { | |
Visible = 'visible', | |
Hidden = 'hidden' | |
} | |
enum Direction { | |
Up = 'Up', | |
Down = 'Down' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Theme { | |
primary: string; | |
accent: string; | |
} | |
@Component({ | |
selector: 'app-root', | |
template: ` | |
<app-card></app-card> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
template: `<app-card></app-card>`, | |
}) | |
export class AppComponent { | |
// ... | |
randomTheme(): Theme { | |
const primary = this.randomHex(); | |
const accent = this.randomHex(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-root', | |
template: `<app-card></app-card>`, | |
}) | |
export class AppComponent { | |
// ... | |
@HostBinding('style') | |
get style() { | |
return this.sanitizer.bypassSecurityTrustStyle( |