Skip to content

Instantly share code, notes, and snippets.

@webia1
Forked from LironHazan/registerTransitionEnd.ts
Created January 26, 2022 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webia1/0638be7c748125baad7dcef720a971c1 to your computer and use it in GitHub Desktop.
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
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