mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-17 07:50:12 +01:00
Change pageTop bg onScroll.
This commit is contained in:
parent
0b399a4a1b
commit
d5dab605a9
4 changed files with 34 additions and 3 deletions
1
src/app/theme/directives/index.ts
Normal file
1
src/app/theme/directives/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
export * from './scrollPosition.directive';
|
||||||
23
src/app/theme/directives/scrollPosition.directive.ts
Normal file
23
src/app/theme/directives/scrollPosition.directive.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
import {Directive, Input, Output, EventEmitter, HostListener, ElementRef} from 'angular2/core';
|
||||||
|
@Directive({
|
||||||
|
selector: '[scrollPosition]'
|
||||||
|
})
|
||||||
|
export class ScrollPosition {
|
||||||
|
@Input() maxHeight: Number;
|
||||||
|
@Output() scrollChange:EventEmitter<Boolean> = new EventEmitter<Boolean>();
|
||||||
|
|
||||||
|
private _isScrolled: Boolean;
|
||||||
|
|
||||||
|
ngOnInit() {
|
||||||
|
this.onWindowScroll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@HostListener('window:scroll')
|
||||||
|
onWindowScroll() : void {
|
||||||
|
let isScrolled = window.scrollY > this.maxHeight;
|
||||||
|
if (isScrolled !== this._isScrolled) {
|
||||||
|
this._isScrolled = isScrolled;
|
||||||
|
this.scrollChange.emit(isScrolled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,12 +2,19 @@ import {Component, ViewEncapsulation} from 'angular2/core';
|
||||||
|
|
||||||
import {MsgCenter} from '../msgCenter';
|
import {MsgCenter} from '../msgCenter';
|
||||||
import {ProfilePicturePipe} from '../pipes/image/profile-picture.pipe';
|
import {ProfilePicturePipe} from '../pipes/image/profile-picture.pipe';
|
||||||
|
import {ScrollPosition} from '../directives/scrollPosition.directive';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'page-top',
|
selector: 'page-top',
|
||||||
styles: [ require('./pageTop.scss') ],
|
styles: [ require('./pageTop.scss') ],
|
||||||
template: require('./pageTop.html'),
|
template: require('./pageTop.html'),
|
||||||
directives: [MsgCenter],
|
directives: [MsgCenter, ScrollPosition],
|
||||||
pipes: [ProfilePicturePipe]
|
pipes: [ProfilePicturePipe]
|
||||||
})
|
})
|
||||||
export class PageTop {}
|
export class PageTop {
|
||||||
|
isScrolled: Boolean = false;
|
||||||
|
|
||||||
|
scrolledChanged(isScrolled) {
|
||||||
|
this.isScrolled = isScrolled;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="page-top clearfix" scroll-position="scrolled" max-height="50" ng-class="{'scrolled': scrolled}">
|
<div class="page-top clearfix" scrollPosition maxHeight="50" (scrollChange)="scrolledChanged($event)" [ngClass]="{scrolled: isScrolled}">
|
||||||
<a href="#/dashboard" class="al-logo clearfix"><span>Blur</span>Admin</a>
|
<a href="#/dashboard" class="al-logo clearfix"><span>Blur</span>Admin</a>
|
||||||
<a href class="collapse-menu-link ion-navicon" ng-click="isMenuCollapsed=!isMenuCollapsed"></a>
|
<a href class="collapse-menu-link ion-navicon" ng-click="isMenuCollapsed=!isMenuCollapsed"></a>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue