aboutsummaryrefslogtreecommitdiff
path: root/js/src/carousel.js
diff options
context:
space:
mode:
authorXhmikosR <[email protected]>2021-11-09 15:44:14 +0200
committerXhmikosR <[email protected]>2022-01-29 13:25:30 +0200
commit558002f3dccb9fcb1ba408abfbe55d201af4e152 (patch)
tree4d42713ff925bfd5edd9132782f511821283eae3 /js/src/carousel.js
parent7d3bc44bb0257baff2728ed0ec97c81cb636bcf5 (diff)
downloadbootstrap-558002f3dccb9fcb1ba408abfbe55d201af4e152.tar.xz
bootstrap-558002f3dccb9fcb1ba408abfbe55d201af4e152.zip
Return early in more places
Diffstat (limited to 'js/src/carousel.js')
-rw-r--r--js/src/carousel.js32
1 files changed, 17 insertions, 15 deletions
diff --git a/js/src/carousel.js b/js/src/carousel.js
index fe3ccf94e..5a0cbc208 100644
--- a/js/src/carousel.js
+++ b/js/src/carousel.js
@@ -225,22 +225,24 @@ class Carousel extends BaseComponent {
}
const endCallBack = () => {
- if (this._config.pause === 'hover') {
- // If it's a touch-enabled device, mouseenter/leave are fired as
- // part of the mouse compatibility events on first tap - the carousel
- // would stop cycling until user tapped out of it;
- // here, we listen for touchend, explicitly pause the carousel
- // (as if it's the second time we tap on it, mouseenter compat event
- // is NOT fired) and after a timeout (to allow for mouse compatibility
- // events to fire) we explicitly restart cycling
-
- this.pause()
- if (this.touchTimeout) {
- clearTimeout(this.touchTimeout)
- }
-
- this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
+ if (this._config.pause !== 'hover') {
+ return
}
+
+ // If it's a touch-enabled device, mouseenter/leave are fired as
+ // part of the mouse compatibility events on first tap - the carousel
+ // would stop cycling until user tapped out of it;
+ // here, we listen for touchend, explicitly pause the carousel
+ // (as if it's the second time we tap on it, mouseenter compat event
+ // is NOT fired) and after a timeout (to allow for mouse compatibility
+ // events to fire) we explicitly restart cycling
+
+ this.pause()
+ if (this.touchTimeout) {
+ clearTimeout(this.touchTimeout)
+ }
+
+ this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval)
}
const swipeConfig = {