Last active
January 26, 2022 07:50
-
-
Save LironHazan/122d343b69905493528b778ca61aba43 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