Created
April 4, 2012 19:11
-
-
Save jbclements/2304837 to your computer and use it in GitHub Desktop.
Excerpt from twitter/bootstrap docs/assets/js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
, slide: function (type, next) { | |
var $active = this.$element.find('.active') | |
, $next = next || $active[type]() | |
, isCycling = this.interval | |
, direction = type == 'next' ? 'left' : 'right' | |
, fallback = type == 'next' ? 'first' : 'last' | |
, that = this | |
this.sliding = true | |
isCycling && this.pause() | |
$next = $next.length ? $next : this.$element.find('.item')[fallback]() | |
if ($next.hasClass('active')) return | |
if (!$.support.transition && this.$element.hasClass('slide')) { | |
this.$element.trigger('slide') | |
$active.removeClass('active') | |
$next.addClass('active') | |
this.sliding = false | |
this.$element.trigger('slid') | |
} else { | |
$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(' ')) | |
that.sliding = false | |
setTimeout(function () { that.$element.trigger('slid') }, 0) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment