Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add special transitionend type to test event origin #13786

Merged
merged 1 commit into from
Jun 12, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

$.support.transition && $parent.hasClass('fade') ?
$parent
.one($.support.transition.end, removeElement)
.one('bsTransitionEnd', removeElement)
.emulateTransitionEnd(150) :
removeElement()
}
Expand Down
2 changes: 1 addition & 1 deletion js/carousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
$active.addClass(direction)
$next.addClass(direction)
$active
.one($.support.transition.end, function () {
.one('bsTransitionEnd', function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
that.sliding = false
Expand Down
19 changes: 4 additions & 15 deletions js/collapse.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,12 @@

this.transitioning = 1

var complete = function (e) {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
var complete = function () {
this.$element
.removeClass('collapsing')
.addClass('collapse in')[dimension]('')
this.transitioning = 0
this.$element
.off($.support.transition.end + '.bs.collapse')
.trigger('shown.bs.collapse')
}

Expand All @@ -81,7 +75,7 @@
var scrollSize = $.camelCase(['scroll', dimension].join('-'))

this.$element
.on($.support.transition.end + '.bs.collapse', $.proxy(complete, this))
.one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350)[dimension](this.$element[0][scrollSize])
}

Expand All @@ -103,12 +97,7 @@

this.transitioning = 1

var complete = function (e) {
if (e && e.target != this.$element[0]) {
this.$element
.one($.support.transition.end, $.proxy(complete, this))
return
}
var complete = function () {
this.transitioning = 0
this.$element
.trigger('hidden.bs.collapse')
Expand All @@ -120,7 +109,7 @@

this.$element
[dimension](0)
.one($.support.transition.end, $.proxy(complete, this))
.one('bsTransitionEnd', $.proxy(complete, this))
.emulateTransitionEnd(350)
}

Expand Down
8 changes: 4 additions & 4 deletions js/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

transition ?
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)
})
.emulateTransitionEnd(300) :
Expand Down Expand Up @@ -122,7 +122,7 @@

$.support.transition && this.$element.hasClass('fade') ?
this.$element
.one($.support.transition.end, $.proxy(this.hideModal, this))
.one('bsTransitionEnd', $.proxy(this.hideModal, this))
.emulateTransitionEnd(300) :
this.hideModal()
}
Expand Down Expand Up @@ -185,7 +185,7 @@

doAnimate ?
this.$backdrop
.one($.support.transition.end, callback)
.one('bsTransitionEnd', callback)
.emulateTransitionEnd(150) :
callback()

Expand All @@ -198,7 +198,7 @@
}
$.support.transition && this.$element.hasClass('fade') ?
this.$backdrop
.one($.support.transition.end, callbackRemove)
.one('bsTransitionEnd', callbackRemove)
.emulateTransitionEnd(150) :
callbackRemove()

Expand Down
2 changes: 1 addition & 1 deletion js/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@

transition ?
$active
.one($.support.transition.end, next)
.one('bsTransitionEnd', next)
.emulateTransitionEnd(150) :
next()

Expand Down
4 changes: 2 additions & 2 deletions js/tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

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

$.support.transition && this.$tip.hasClass('fade') ?
$tip
.one($.support.transition.end, complete)
.one('bsTransitionEnd', complete)
.emulateTransitionEnd(150) :
complete()

Expand Down
12 changes: 11 additions & 1 deletion js/transition.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,24 @@
$.fn.emulateTransitionEnd = function (duration) {
var called = false
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) }
setTimeout(callback, duration)
return this
}

$(function () {
$.support.transition = transitionEnd()

if (!$.support.transition) return

$.event.special.bsTransitionEnd = {
bindType: $.support.transition.end,
delegateType: $.support.transition.end,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be more like ($.support.transition && $.support.transition.end) || false for it to be null safe? Also, does jQuery care if these are false?

Edit: Or we could wrap this in a conditional to check if transitions are supported

handle: function (e) {
if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
}
}
})

});