1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-09-25 21:09:06 +02:00

add preventDefault support for all inital event types (show, close, hide, etc.) + fix small bug with scrollspy.last

This commit is contained in:
Jacob Thornton
2012-03-24 18:20:09 -07:00
parent ef5ac02b69
commit bccc2cb719
16 changed files with 128 additions and 32 deletions

View File

@@ -86,6 +86,7 @@
, direction = type == 'next' ? 'left' : 'right'
, fallback = type == 'next' ? 'first' : 'last'
, that = this
, e = $.Event('slide')
this.sliding = true
@@ -96,11 +97,12 @@
if ($next.hasClass('active')) return
if ($.support.transition && this.$element.hasClass('slide')) {
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$next.addClass(type)
$next[0].offsetWidth // force reflow
$active.addClass(direction)
$next.addClass(direction)
this.$element.trigger('slide')
this.$element.one($.support.transition.end, function () {
$next.removeClass([type, direction].join(' ')).addClass('active')
$active.removeClass(['active', direction].join(' '))
@@ -108,7 +110,8 @@
setTimeout(function () { that.$element.trigger('slid') }, 0)
})
} else {
this.$element.trigger('slide')
this.$element.trigger(e)
if (e.isDefaultPrevented()) return
$active.removeClass('active')
$next.addClass('active')
this.sliding = false