Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohann-S <johann.servoire@gmail.com>2015-09-27 02:30:11 +0300
committerChris Rebert <code@chrisrebert.com>2015-10-12 01:10:49 +0300
commit817d997b75d970cc22000f345f68092ed3f0525b (patch)
tree662f82d45a1989aaf3e02d5270550692a87d12cf /js/src/carousel.js
parent9b12e5f495535aa64bcf77703c51b17742ec7f06 (diff)
Use Page Visibility API in Carousel; fixes #17706
Avoids cycling carousels when the page isn't visible. Closes #17710 Refs #15566
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index d8da854a22..8d47fbf9b4 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
)
}
}