Tracking scroll position and notifying other components about it. I think the easiest way is each interested component listening to the scroll event.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
@Component({ ... // alternative to `@HostListener(...)` // host: {'(window:scroll)': 'doSomething($event)'} }) class SomeComponent { @HostListener('window:scroll', ['$event']) doSomething(event) { // console.debug("Scroll Event", document.body.scrollTop); // see András Szepesházi's comment below console.debug("Scroll Event", window.pageYOffset ); } } |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.