Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

EventTarget.prototype.onTransitionEnd()

This is a helper which adds onTransitionEnd() to EventTarget.

Inspired from bootstrap’s implementation, but without any jQuery dependency.

How it works

It checks which transitionEnd is supported by the client:
'webkitTransitionEnd', 'transitionend', 'oTransitionEnd otransitionend', 'transitionend'

And if it’s not supported (IE8 etc.) it will dispatch an transitionend event after the provided transitionDuration.

Unlike target.addEventListener('transitionend', fn), this will not trigger when a child has finished it’s transition.

Syntax

target.onTransitionEnd(listener, transitionDuration);

Example:

document.querySelector('.button').onTransitionEnd(() => {
  // your code
}, 1000);

About

A prototype for EventTarget which fires onTransitionEnd. It detects which prefix the browser uses and provides fallback for legacy browsers.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors