I'm trying to create a directive that will fadeIn a photo slowly when an element is made visible. To do so, my first idea is comparing the position of an item regarding to the top (also checking the height of the window). But I can find how to do that with Angular2.
This is my code so far:
import {Directive, ElementRef, Renderer} from 'angular2/core';
@Directive({
selector: '[fadeInPhoto]',
host: {
'(window:scroll)': 'onScroll()'
}
})
export class FadeInPhotoDirective{
private scrollTop: number;
private initialClass: string;
constructor(private _el: ElementRef, private _renderer: Renderer){
this.initialClass = 'thumbnail';
}
onScroll(){
console.log('Photo top:', this._el);
}
}
But this._el doesn't seem to have any method or property that contains that information.