Merge pull request #13786 from twbs/fat-13430

add special transitionend type to test event origin
This commit is contained in:
Jacob 2014-06-11 22:44:04 -07:00
commit 696632d7da
7 changed files with 24 additions and 25 deletions

View File

@ -54,7 +54,7 @@
$.support.transition && $parent.hasClass('fade') ? $.support.transition && $parent.hasClass('fade') ?
$parent $parent
.one($.support.transition.end, removeElement) .one('bsTransitionEnd', removeElement)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
removeElement() removeElement()
} }

View File

@ -142,7 +142,7 @@
$active.addClass(direction) $active.addClass(direction)
$next.addClass(direction) $next.addClass(direction)
$active $active
.one($.support.transition.end, function () { .one('bsTransitionEnd', function () {
$next.removeClass([type, direction].join(' ')).addClass('active') $next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' ')) $active.removeClass(['active', direction].join(' '))
that.sliding = false that.sliding = false

View File

@ -61,18 +61,12 @@
this.transitioning = 1 this.transitioning = 1
var complete = function (e) { var complete = function () {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
this.$element this.$element
.removeClass('collapsing') .removeClass('collapsing')
.addClass('collapse in')[dimension]('') .addClass('collapse in')[dimension]('')
this.transitioning = 0 this.transitioning = 0
this.$element this.$element
.off($.support.transition.end + '.bs.collapse')
.trigger('shown.bs.collapse') .trigger('shown.bs.collapse')
} }
@ -81,7 +75,7 @@
var scrollSize = $.camelCase(['scroll', dimension].join('-')) var scrollSize = $.camelCase(['scroll', dimension].join('-'))
this.$element this.$element
.on($.support.transition.end + '.bs.collapse', $.proxy(complete, this)) .one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize]) .emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
} }
@ -103,12 +97,7 @@
this.transitioning = 1 this.transitioning = 1
var complete = function (e) { var complete = function () {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
this.transitioning = 0 this.transitioning = 0
this.$element this.$element
.trigger('hidden.bs.collapse') .trigger('hidden.bs.collapse')
@ -120,7 +109,7 @@
this.$element this.$element
[dimension](0) [dimension](0)
.one($.support.transition.end, $.proxy(complete, this)) .one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350) .emulateTransitionEnd(350)
} }

View File

@ -89,7 +89,7 @@
transition ? transition ?
that.$element.find('.modal-dialog') // wait for modal to slide in that.$element.find('.modal-dialog') // wait for modal to slide in
.one($.support.transition.end, function () { .one('bsTransitionEnd', function () {
that.$element.trigger('focus').trigger(e) that.$element.trigger('focus').trigger(e)
}) })
.emulateTransitionEnd(300) : .emulateTransitionEnd(300) :
@ -122,7 +122,7 @@
$.support.transition && this.$element.hasClass('fade') ? $.support.transition && this.$element.hasClass('fade') ?
this.$element this.$element
.one($.support.transition.end, $.proxy(this.hideModal, this)) .one('bsTransitionEnd', $.proxy(this.hideModal, this))
.emulateTransitionEnd(300) : .emulateTransitionEnd(300) :
this.hideModal() this.hideModal()
} }
@ -185,7 +185,7 @@
doAnimate ? doAnimate ?
this.$backdrop this.$backdrop
.one($.support.transition.end, callback) .one('bsTransitionEnd', callback)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
callback() callback()
@ -198,7 +198,7 @@
} }
$.support.transition && this.$element.hasClass('fade') ? $.support.transition && this.$element.hasClass('fade') ?
this.$backdrop this.$backdrop
.one($.support.transition.end, callbackRemove) .one('bsTransitionEnd', callbackRemove)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
callbackRemove() callbackRemove()

View File

@ -85,7 +85,7 @@
transition ? transition ?
$active $active
.one($.support.transition.end, next) .one('bsTransitionEnd', next)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
next() next()

View File

@ -210,7 +210,7 @@
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
$tip $tip
.one($.support.transition.end, complete) .one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
complete() complete()
} }
@ -298,7 +298,7 @@
$.support.transition && this.$tip.hasClass('fade') ? $.support.transition && this.$tip.hasClass('fade') ?
$tip $tip
.one($.support.transition.end, complete) .one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) : .emulateTransitionEnd(150) :
complete() complete()

View File

@ -40,7 +40,7 @@
$.fn.emulateTransitionEnd = function (duration) { $.fn.emulateTransitionEnd = function (duration) {
var called = false var called = false
var $el = this var $el = this
$(this).one($.support.transition.end, function () { called = true }) $(this).one('bsTransitionEnd', function () { called = true })
var callback = function () { if (!called) $($el).trigger($.support.transition.end) } var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
setTimeout(callback, duration) setTimeout(callback, duration)
return this return this
@ -48,6 +48,16 @@
$(function () { $(function () {
$.support.transition = transitionEnd() $.support.transition = transitionEnd()
if (!$.support.transition) return
$.event.special.bsTransitionEnd = {
bindType: $.support.transition.end,
delegateType: $.support.transition.end,
handle: function (e) {
if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
}
}
}) })
}); });