W3cubDocs

/DOM Events

transitionrun

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

The transitionrun event is fired when a CSS transition is first created, i.e. before any transition-delay has begun.

General info

Bubbles Yes
Cancelable No
Target objects document, element
Interface TransitionEvent

Properties

Property Type Description
target Read only EventTarget The event target (the topmost target in the DOM tree).
type Read only DOMString The type of event.
bubblesRead only Boolean Whether the event normally bubbles or not
cancelable Read only Boolean Whether the event is cancellable or not?
propertyName Read only DOMString The name of the CSS property associated with the transition.
elapsedTime Read only Float The amount of time the transition has been running, in seconds, as of the time the event was generated. This value is not affected by the value of transition-delay.
pseudoElement Read only DOMString The name (beginning with two colons) of the CSS pseudo-element on which the transition occured (in which case the target of the event is that pseudo-element's corresponding element), or the empty string if the transition occurred on an element (which means the target of the event is that element).

Examples

In the following example, we have a simple <div> element, styled with a transition that includes a delay:

<div></div>
div {
  width: 200px;
  height: 200px;
  background: rgba(255,0,0,1);
  transition-property: transform background;
  transition-duration: 2s;
  transition-delay: 2s;
}

div:hover {
  transform: rotate(90deg);
  background: rgba(255,0,0,0);
}

To this, we'll add some JavaScript to indicate where the transitionstart and transitionrun events fire.

var divElem = document.querySelector('div');

divElem.addEventListener('transitionrun', function() {
  console.log('transitionrun fired');
});

divElem.addEventListener('transitionstart', function() {
  console.log('transitionstart fired');
});

The difference is that:

  • transitionrun fires when the transition is created (i.e. at the start of any delay).
  • transitionstart fires when the actual animation has begun (i.e. at the end of any delay).

Specifications

Specification Status Comment
CSS Transitions Level 2
The definition of 'transitionstart' in that specification.
Editor's Draft Initial definition.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support ? No support 53 (53) No support ? ?
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? No support 53.0 (53) No support ? ?

See also

© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/Events/transitionrun