this.cycle(true)
}
- clearInterval(this._interval)
- this._interval = null
+ this._clearInterval()
}
cycle(event) {
this._isPaused = false
}
- if (this._interval) {
- clearInterval(this._interval)
- this._interval = null
- }
-
+ this._clearInterval()
if (this._config.interval && !this._isPaused) {
this._updateInterval()
return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)
}
+ _clearInterval() {
+ if (this._interval) {
+ clearInterval(this._interval)
+ this._interval = null
+ }
+ }
+
_directionToOrder(direction) {
if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) {
return direction
const carousel = new Carousel(carouselEl)
spyOn(carousel, 'cycle')
- spyOn(window, 'clearInterval')
+ spyOn(carousel, '_clearInterval')
carousel.pause()
expect(carousel.cycle).toHaveBeenCalledWith(true)
- expect(window.clearInterval).toHaveBeenCalled()
+ expect(carousel._clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toBeTrue()
})
const carousel = new Carousel(carouselEl)
spyOn(carousel, 'cycle')
- spyOn(window, 'clearInterval')
+ spyOn(carousel, '_clearInterval')
carousel.pause()
expect(carousel.cycle).not.toHaveBeenCalled()
- expect(window.clearInterval).toHaveBeenCalled()
+ expect(carousel._clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toBeTrue()
})
const carousel = new Carousel(carouselEl)
const event = createEvent('mouseenter')
- spyOn(window, 'clearInterval')
+ spyOn(carousel, '_clearInterval')
carousel.pause(event)
- expect(window.clearInterval).toHaveBeenCalled()
+ expect(carousel._clearInterval).toHaveBeenCalled()
expect(carousel._isPaused).toBeFalse()
})
})