Skip to content
This repository was archived by the owner on Feb 24, 2023. It is now read-only.

Commit b3d012c

Browse files
author
Łukasz Florczak
committed
Small change in listeners
1 parent 3b4c248 commit b3d012c

File tree

1 file changed

+27
-30
lines changed

1 file changed

+27
-30
lines changed

src/Agile.vue

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -181,40 +181,37 @@
181181
this.startAutoplay()
182182
}
183183
184-
// Listeners
185-
this.$nextTick(function () {
186-
// Windows resize listener
187-
window.addEventListener('resize', this.getWidth)
188-
189-
// Get width on start
190-
this.getWidth()
191-
192-
// Mouse and touch events
193-
if ('ontouchstart' in window) {
194-
this.el.track.addEventListener('touchstart', this.handleMouseDown)
195-
this.el.track.addEventListener('touchend', this.handleMouseUp)
196-
this.el.track.addEventListener('touchmove', this.handleMouseMove)
197-
} else {
198-
this.el.track.addEventListener('mousedown', this.handleMouseDown)
199-
this.el.track.addEventListener('mouseup', this.handleMouseUp)
200-
this.el.track.addEventListener('mousemove', this.handleMouseMove)
201-
}
184+
// Windows resize listener
185+
window.addEventListener('resize', this.getWidth)
202186
203-
// Autoplay
204-
if (this.autoplay_) {
205-
if (this.pauseOnHover_) {
206-
this.el.track.addEventListener('mouseover', this.stopAutoplay)
207-
this.el.track.addEventListener('mouseout', this.startAutoplay)
208-
}
187+
// Get width on start
188+
this.getWidth()
189+
190+
// Mouse and touch events
191+
if ('ontouchstart' in window) {
192+
this.el.track.addEventListener('touchstart', this.handleMouseDown)
193+
this.el.track.addEventListener('touchend', this.handleMouseUp)
194+
this.el.track.addEventListener('touchmove', this.handleMouseMove)
195+
} else {
196+
this.el.track.addEventListener('mousedown', this.handleMouseDown)
197+
this.el.track.addEventListener('mouseup', this.handleMouseUp)
198+
this.el.track.addEventListener('mousemove', this.handleMouseMove)
199+
}
209200
210-
if (this.pauseOnDotsHover_) {
211-
for (let i = 0; i < this.slidesCount; ++i) {
212-
this.el.dots[i].addEventListener('mouseover', this.stopAutoplay)
213-
this.el.dots[i].addEventListener('mouseout', this.startAutoplay)
214-
}
201+
// Autoplay
202+
if (this.autoplay_) {
203+
if (this.pauseOnHover_) {
204+
this.el.track.addEventListener('mouseover', this.stopAutoplay)
205+
this.el.track.addEventListener('mouseout', this.startAutoplay)
206+
}
207+
208+
if (this.pauseOnDotsHover_) {
209+
for (let i = 0; i < this.slidesCount; ++i) {
210+
this.el.dots[i].addEventListener('mouseover', this.stopAutoplay)
211+
this.el.dots[i].addEventListener('mouseout', this.startAutoplay)
215212
}
216213
}
217-
})
214+
}
218215
},
219216
220217
beforeDestroy () {

0 commit comments

Comments
 (0)