From 54e053052a200781f76d208b8ccc911957239e63 Mon Sep 17 00:00:00 2001 From: Johnathan Howard Date: Wed, 14 Feb 2018 09:09:20 -0500 Subject: [PATCH 1/2] adding an event to output an notification when the scrolling has completed. --- src/scrollTo.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/scrollTo.ts b/src/scrollTo.ts index ca81329..63a8871 100644 --- a/src/scrollTo.ts +++ b/src/scrollTo.ts @@ -1,4 +1,5 @@ -import { Directive, ElementRef, Input, HostListener } from '@angular/core'; +import { Directive, ElementRef, Input, HostListener, Output, EventEmitter } from '@angular/core'; + @Directive({ selector: '[scrollTo]' }) @@ -7,6 +8,7 @@ export class ScrollTo { @Input() scrollTargetSelector: string; @Input() scrollYTarget: number; @Input() scrollOffSet: number; + @Output() notifiyScrollToDone = new EventEmitter(); constructor(private el: ElementRef) { } @HostListener('click', ['$event']) onClick(event: MouseEvent) { @@ -79,6 +81,7 @@ export class ScrollTo { let position = this.position(start, end, elapsed, duration); element.scrollTop = position; if (elapsed > duration) { + this.notifiyScrollToDone.emit(); } else { requestAnimationFrame(step); } From 8951ab746f9ccc52226259b1547fd006608e1db0 Mon Sep 17 00:00:00 2001 From: Johnathan Howard Date: Wed, 14 Feb 2018 09:26:20 -0500 Subject: [PATCH 2/2] correct spelling --- src/scrollTo.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scrollTo.ts b/src/scrollTo.ts index 63a8871..f571118 100644 --- a/src/scrollTo.ts +++ b/src/scrollTo.ts @@ -8,7 +8,7 @@ export class ScrollTo { @Input() scrollTargetSelector: string; @Input() scrollYTarget: number; @Input() scrollOffSet: number; - @Output() notifiyScrollToDone = new EventEmitter(); + @Output() notifyScrollToDone = new EventEmitter(); constructor(private el: ElementRef) { } @HostListener('click', ['$event']) onClick(event: MouseEvent) { @@ -81,7 +81,7 @@ export class ScrollTo { let position = this.position(start, end, elapsed, duration); element.scrollTop = position; if (elapsed > duration) { - this.notifiyScrollToDone.emit(); + this.notifyScrollToDone.emit(); } else { requestAnimationFrame(step); }