Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript: Is there a CSS transition start event?

I found the transition end events, but I need a transition start event. Is there such thing?

like image 456
barakuda28 Avatar asked Jan 19 '14 15:01

barakuda28


People also ask

What triggers CSS transition?

Triggering transitions You can trigger CSS transitions directly with pseudo classes like :hover (activates when the mouse goes over an element), :focus (activates when a user tabs onto an element, or when a user clicks into an input element), or :active (activates when user clicks on the element).

What is Transitionend in JavaScript?

The transitionend event is fired when a CSS transition has completed. In the case where a transition is removed before completion, such as if the transition-property is removed or display is set to none , then the event will not be generated.

What does CSS Transition do?

CSS transitions provide a way to control animation speed when changing CSS properties. Instead of having property changes take effect immediately, you can cause the changes in a property to take place over a period of time.

What is Transitionend?

The transitionend event occurs when a CSS transition has completed. Note: If the transition is removed before completion, e.g. if the CSS transition-property property is removed, the transitionend event will not fire. For more information about CSS Transitions, see our tutorial on CSS3 Transitions.


1 Answers

No, not yet. (reiterating @Frédéric Hamidi's comment.)

Consider broadcasting your own event with an event aggregator, mediator, or pub/sub. These all mean basically the same thing: Instead of waiting for JavaScript's DOM/CSS event specs to catch up with your needs, make your own global/near-global event management system, or use custom events in whatever event framework you're already using.

For example, you can use custom jQuery events:

// Transition target (body, for example) var $body = jQuery(document.body);  // Register our transition starting function (left as exercise) $body.on('transition_start', startFunction);  // Start the transition... $body.addClass('transitioning')     // ... and let everyone know     .trigger('transition_start');` 
like image 160
Reed Spool Avatar answered Sep 30 '22 02:09

Reed Spool