Bez popisu

transition.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* ========================================================================
  2. * Bootstrap: transition.js v3.4.1
  3. * https://getbootstrap.com/docs/3.4/javascript/#transitions
  4. * ========================================================================
  5. * Copyright 2011-2019 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: https://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. // https://blog.alexmaccaw.com/css-transitions
  28. $.fn.emulateTransitionEnd = function (duration) {
  29. var called = false
  30. var $el = this
  31. $(this).one('bsTransitionEnd', function () { called = true })
  32. var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
  33. setTimeout(callback, duration)
  34. return this
  35. }
  36. $(function () {
  37. $.support.transition = transitionEnd()
  38. if (!$.support.transition) return
  39. $.event.special.bsTransitionEnd = {
  40. bindType: $.support.transition.end,
  41. delegateType: $.support.transition.end,
  42. handle: function (e) {
  43. if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
  44. }
  45. }
  46. })
  47. }(jQuery);