Skip to content

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

Notifications You must be signed in to change notification settings

JasonMHasperhoven/onTransitionEnd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 

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

Watchers

Forks

Releases

No releases published

Packages

No packages published