From 21a65f181eebc3f2c0cd43fb3383ee3de673745b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Wed, 16 Sep 2015 10:35:29 +0200 Subject: Add throw error for undefined method on plugins --- js/src/carousel.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'js/src/carousel.js') diff --git a/js/src/carousel.js b/js/src/carousel.js index efacd9494..d8da854a2 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -390,10 +390,11 @@ const Carousel = (($) => { if (typeof config === 'number') { data.to(config) - - } else if (action) { + } else if (typeof action === 'string') { + if (data[action] === undefined) { + throw new Error(`No method named "${action}"`) + } data[action]() - } else if (_config.interval) { data.pause() data.cycle() -- cgit v1.2.3 From 817d997b75d970cc22000f345f68092ed3f0525b Mon Sep 17 00:00:00 2001 From: Johann-S Date: Sun, 27 Sep 2015 01:30:11 +0200 Subject: Use Page Visibility API in Carousel; fixes #17706 Avoids cycling carousels when the page isn't visible. Closes #17710 Refs #15566 --- js/src/carousel.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'js/src/carousel.js') diff --git a/js/src/carousel.js b/js/src/carousel.js index d8da854a2..8d47fbf9b 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -119,6 +119,13 @@ const Carousel = (($) => { } } + nextWhenVisible() { + // Don't call next when the page isn't visible + if (!document.hidden) { + this.next() + } + } + prev() { if (!this._isSliding) { this._slide(Direction.PREVIOUS) @@ -152,7 +159,7 @@ const Carousel = (($) => { if (this._config.interval && !this._isPaused) { this._interval = setInterval( - $.proxy(this.next, this), this._config.interval + $.proxy(document.visibilityState ? this.nextWhenVisible : this.next, this), this._config.interval ) } } -- cgit v1.2.3 From 75c39f9138ea95e8d472812117b13f1ed7978157 Mon Sep 17 00:00:00 2001 From: Chris Rebert Date: Sat, 5 Dec 2015 02:19:21 -0800 Subject: Fix version numbers is JS files; fixes #18435 [skip sauce] [skip validator] --- js/src/carousel.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/src/carousel.js') diff --git a/js/src/carousel.js b/js/src/carousel.js index 8d47fbf9b..3abb06466 100644 --- a/js/src/carousel.js +++ b/js/src/carousel.js @@ -3,7 +3,7 @@ import Util from './util' /** * -------------------------------------------------------------------------- - * Bootstrap (v4.0.0): carousel.js + * Bootstrap (v4.0.0-alpha): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ const Carousel = (($) => { */ const NAME = 'carousel' - const VERSION = '4.0.0' + const VERSION = '4.0.0-alpha' const DATA_KEY = 'bs.carousel' const EVENT_KEY = `.${DATA_KEY}` const DATA_API_KEY = '.data-api' -- cgit v1.2.3