transition.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /* ========================================================================
  2. * Bootstrap: transition.js v3.0.3
  3. * http://getbootstrap.com/javascript/#transitions
  4. * ========================================================================
  5. * Copyright 2013 Twitter, Inc.
  6. *
  7. * Licensed under the Apache License, Version 2.0 (the "License");
  8. * you may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. * ======================================================================== */
  19. +function ($) { "use strict";
  20. // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
  21. // ============================================================
  22. function transitionEnd() {
  23. var el = document.createElement('bootstrap')
  24. var transEndEventNames = {
  25. 'WebkitTransition' : 'webkitTransitionEnd'
  26. , 'MozTransition' : 'transitionend'
  27. , 'OTransition' : 'oTransitionEnd otransitionend'
  28. , 'transition' : 'transitionend'
  29. }
  30. for (var name in transEndEventNames) {
  31. if (el.style[name] !== undefined) {
  32. return { end: transEndEventNames[name] }
  33. }
  34. }
  35. }
  36. // http://blog.alexmaccaw.com/css-transitions
  37. $.fn.emulateTransitionEnd = function (duration) {
  38. var called = false, $el = this
  39. $(this).one($.support.transition.end, function () { called = true })
  40. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  41. setTimeout(callback, duration)
  42. return this
  43. }
  44. $(function () {
  45. $.support.transition = transitionEnd()
  46. })
  47. }(jQuery);