mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-23 02:40:14 +01:00
23 lines
No EOL
656 B
TypeScript
23 lines
No EOL
656 B
TypeScript
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);
|
|
}
|
|
}
|
|
} |