mirror of
https://github.com/Hopiu/bootstrap.git
synced 2026-05-14 07:03:09 +00:00
Return early in more places
This commit is contained in:
parent
7d3bc44bb0
commit
558002f3dc
2 changed files with 27 additions and 23 deletions
|
|
@ -225,22 +225,24 @@ class Carousel extends BaseComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
const endCallBack = () => {
|
const endCallBack = () => {
|
||||||
if (this._config.pause === 'hover') {
|
if (this._config.pause !== 'hover') {
|
||||||
// If it's a touch-enabled device, mouseenter/leave are fired as
|
return
|
||||||
// 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 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 = {
|
const swipeConfig = {
|
||||||
|
|
|
||||||
|
|
@ -105,15 +105,17 @@ function bootstrapDelegationHandler(element, selector, fn) {
|
||||||
|
|
||||||
for (let { target } = event; target && target !== this; target = target.parentNode) {
|
for (let { target } = event; target && target !== this; target = target.parentNode) {
|
||||||
for (const domElement of domElements) {
|
for (const domElement of domElements) {
|
||||||
if (domElement === target) {
|
if (domElement !== target) {
|
||||||
event.delegateTarget = target
|
continue
|
||||||
|
|
||||||
if (handler.oneOff) {
|
|
||||||
EventHandler.off(element, event.type, selector, fn)
|
|
||||||
}
|
|
||||||
|
|
||||||
return fn.apply(target, [event])
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.delegateTarget = target
|
||||||
|
|
||||||
|
if (handler.oneOff) {
|
||||||
|
EventHandler.off(element, event.type, selector, fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
return fn.apply(target, [event])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue