-
-
Save webia1/0638be7c748125baad7dcef720a971c1 to your computer and use it in GitHub Desktop.
Amir Baraks's registerTransitionEnd used in an Angular directive for rxjs blog post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
registerTransitionEnd<T extends {propertyName}>(el: FromEventTarget<T>, propName: string) { | |
// Returns an Observable from DOM event | |
fromEvent(el, 'transitionend') | |
.pipe( | |
filter(({ propertyName }: T) => propertyName === propName) // Will only emit value for the wanted css prop name e.g. height | |
) | |
.subscribe((_) => { | |
this.transitionEnd.emit(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment