Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I was using the approach given by Pete, however I have now started using the following </p> <pre><code>$(".myClass").one('transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd', function() { //do something }); </code></pre> <hr> <p>Alternatively if you use bootstrap then you can simply do </p> <pre><code>$(".myClass").one($.support.transition.end, function() { //do something }); </code></pre> <p>This is becuase they include the following in bootstrap.js </p> <pre><code>+function ($) { 'use strict'; // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/) // ============================================================ function transitionEnd() { var el = document.createElement('bootstrap') var transEndEventNames = { 'WebkitTransition' : 'webkitTransitionEnd', 'MozTransition' : 'transitionend', 'OTransition' : 'oTransitionEnd otransitionend', 'transition' : 'transitionend' } for (var name in transEndEventNames) { if (el.style[name] !== undefined) { return { end: transEndEventNames[name] } } } return false // explicit for ie8 ( ._.) } $(function () { $.support.transition = transitionEnd() }) }(jQuery); </code></pre> <p>Note they also include an emulateTransitionEnd function which may be needed to ensure a callback always occurs.</p> <pre><code> // http://blog.alexmaccaw.com/css-transitions $.fn.emulateTransitionEnd = function (duration) { var called = false, $el = this $(this).one($.support.transition.end, function () { called = true }) var callback = function () { if (!called) $($el).trigger($.support.transition.end) } setTimeout(callback, duration) return this } </code></pre> <blockquote> <p>Be aware that sometimes this event doesn’t fire, usually in the case when properties don’t change or a paint isn’t triggered. To ensure we always get a callback, let’s set a timeout that’ll trigger the event manually.</p> </blockquote> <p><a href="http://blog.alexmaccaw.com/css-transitions" rel="noreferrer">http://blog.alexmaccaw.com/css-transitions</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload