transition.js 2.1 KB

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