aboutsummaryrefslogtreecommitdiff
path: root/js/dist/carousel.js
diff options
context:
space:
mode:
authorPierre Vanduynslager <[email protected]>2017-04-08 18:43:25 -0400
committerGitHub <[email protected]>2017-04-08 18:43:25 -0400
commitfe72daf2b34263d3cfc9bc77e9998cd22adfa34d (patch)
tree15dc9fc6fcb513362ba112d52ab01b568b423709 /js/dist/carousel.js
parentf5cc59145642d78d7abbdf38fee1905786da5367 (diff)
parentfeb35b94a61c4d6016be8d1773a79a6bbe57d856 (diff)
downloadbootstrap-fe72daf2b34263d3cfc9bc77e9998cd22adfa34d.tar.xz
bootstrap-fe72daf2b34263d3cfc9bc77e9998cd22adfa34d.zip
Merge branch 'v4-dev' into dropdown-keyboard
Diffstat (limited to 'js/dist/carousel.js')
-rw-r--r--js/dist/carousel.js23
1 files changed, 14 insertions, 9 deletions
diff --git a/js/dist/carousel.js b/js/dist/carousel.js
index 6e4269245..77d6e80d9 100644
--- a/js/dist/carousel.js
+++ b/js/dist/carousel.js
@@ -112,10 +112,9 @@ var Carousel = function ($) {
// public
Carousel.prototype.next = function next() {
- if (this._isSliding) {
- throw new Error('Carousel is sliding');
+ if (!this._isSliding) {
+ this._slide(Direction.NEXT);
}
- this._slide(Direction.NEXT);
};
Carousel.prototype.nextWhenVisible = function nextWhenVisible() {
@@ -126,10 +125,9 @@ var Carousel = function ($) {
};
Carousel.prototype.prev = function prev() {
- if (this._isSliding) {
- throw new Error('Carousel is sliding');
+ if (!this._isSliding) {
+ this._slide(Direction.PREV);
}
- this._slide(Direction.PREV);
};
Carousel.prototype.pause = function pause(event) {
@@ -272,9 +270,13 @@ var Carousel = function ($) {
};
Carousel.prototype._triggerSlideEvent = function _triggerSlideEvent(relatedTarget, eventDirectionName) {
+ var targetIndex = this._getItemIndex(relatedTarget);
+ var fromIndex = this._getItemIndex($(this._element).find(Selector.ACTIVE_ITEM)[0]);
var slideEvent = $.Event(Event.SLIDE, {
relatedTarget: relatedTarget,
- direction: eventDirectionName
+ direction: eventDirectionName,
+ from: fromIndex,
+ to: targetIndex
});
$(this._element).trigger(slideEvent);
@@ -298,8 +300,9 @@ var Carousel = function ($) {
var _this3 = this;
var activeElement = $(this._element).find(Selector.ACTIVE_ITEM)[0];
+ var activeElementIndex = this._getItemIndex(activeElement);
var nextElement = element || activeElement && this._getItemByDirection(direction, activeElement);
-
+ var nextElementIndex = this._getItemIndex(nextElement);
var isCycling = Boolean(this._interval);
var directionalClassName = void 0;
@@ -341,7 +344,9 @@ var Carousel = function ($) {
var slidEvent = $.Event(Event.SLID, {
relatedTarget: nextElement,
- direction: eventDirectionName
+ direction: eventDirectionName,
+ from: activeElementIndex,
+ to: nextElementIndex
});
if (Util.supportsTransitionEnd() && $(this._element).hasClass(ClassName.SLIDE)) {