transition.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /* ========================================================================
  2. * Bootstrap: transition.js v3.1.1
  3. * http://getbootstrap.com/javascript/#transitions
  4. * ========================================================================
  5. * Copyright 2011-2014 Twitter, Inc.
  6. * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  7. * ======================================================================== */
  8. +function ($) {
  9. 'use strict';
  10. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  11. // ============================================================
  12. function transitionEnd() {
  13. var el = document.createElement('bootstrap')
  14. var transEndEventNames = {
  15. 'WebkitTransition' : 'webkitTransitionEnd',
  16. 'MozTransition' : 'transitionend',
  17. 'OTransition' : 'oTransitionEnd otransitionend',
  18. 'transition' : 'transitionend'
  19. }
  20. for (var name in transEndEventNames) {
  21. if (el.style[name] !== undefined) {
  22. return { end: transEndEventNames[name] }
  23. }
  24. }
  25. return false // explicit for ie8 ( ._.)
  26. }
  27. // http://blog.alexmaccaw.com/css-transitions
  28. $.fn.emulateTransitionEnd = function (duration) {
  29. var called = false, $el = this
  30. $(this).one($.support.transition.end, function () { called = true })
  31. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  32. setTimeout(callback, duration)
  33. return this
  34. }
  35. $(function () {
  36. $.support.transition = transitionEnd()
  37. })
  38. }(jQuery);