Closed stevenvachon closed 10 years ago
I've created a plugin with this functionality. No longer a hacked mod like my link above :)
That's a clever piece of code, although doesn't it still depend on you knowing when the transition begins? someEl.addClass('classWithTransitions').afterTransitions()
My plugin's primary goal is to widen the separation of concerns between designer and coder, the less the coder knows about the animations the better.
addClass()
could be extended with transition checks. This slows down all other uses of the function, however.
Consider the following:
div
{
transition: width 2s;
}
div.someTransitionClass
{
width:300px;
}
Detection would involve parsing out which transition properties are currently applied, which ones get applied after, and which properties have changed from before. Animations by comparison can be detected with an arbitrary name at the end of the animation-name property. Not something I'm willing to undertake at this time.
That way everything is in one library, instead of across many.
Here's an
afterTransitions
that I quickly hacked together: https://github.com/ai/transition-events/issues/6#issuecomment-29964462. It basically just grabs a total duration of all transitions for any given element and runs a timeout with an event. It works really well in MVC situations where you're not usingjQuery.remove()
.