aboutsummaryrefslogtreecommitdiff
path: root/js/src/carousel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js16
1 files changed, 9 insertions, 7 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index 86daa0795..5a92f630d 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -13,7 +13,9 @@ import {
getNextActiveElement,
reflow,
triggerTransitionEnd,
- typeCheckConfig
+ typeCheckConfig,
+ getDocument,
+ getWindow
} from './util/index'
import EventHandler from './dom/event-handler'
import Manipulator from './dom/manipulator'
@@ -120,8 +122,8 @@ class Carousel extends BaseComponent {
this._config = this._getConfig(config)
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element)
- this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
- this._pointerEvent = Boolean(window.PointerEvent)
+ this._touchSupported = 'ontouchstart' in this._document.documentElement || this._window.navigator.maxTouchPoints > 0
+ this._pointerEvent = Boolean(this._window.PointerEvent)
this._addEventListeners()
}
@@ -145,7 +147,7 @@ class Carousel extends BaseComponent {
nextWhenVisible() {
// Don't call next when the page isn't visible
// or the carousel or its parent isn't visible
- if (!document.hidden && isVisible(this._element)) {
+ if (!this._document.hidden && isVisible(this._element)) {
this.next()
}
}
@@ -182,7 +184,7 @@ class Carousel extends BaseComponent {
this._updateInterval()
this._interval = setInterval(
- (document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
+ (this._document.visibilityState ? this.nextWhenVisible : this.next).bind(this),
this._config.interval
)
}
@@ -569,9 +571,9 @@ class Carousel extends BaseComponent {
* ------------------------------------------------------------------------
*/
-EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
+EventHandler.on(getDocument(), EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
-EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
+EventHandler.on(getWindow(), EVENT_LOAD_DATA_API, () => {
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE)
for (let i = 0, len = carousels.length; i < len; i++) {