scrollPosition - baScrollPosition

This commit is contained in:
nixa 2016-05-18 16:45:01 +03:00
parent 8b673b1f48
commit 5f360a73a8
6 changed files with 12 additions and 11 deletions

View file

@ -1,24 +0,0 @@
import {Directive, Input, Output, EventEmitter, HostListener} from '@angular/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);
}
}
}