|
181 | 181 | this.startAutoplay()
|
182 | 182 | }
|
183 | 183 |
|
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) |
202 | 186 |
|
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 | + } |
209 | 200 |
|
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) |
215 | 212 | }
|
216 | 213 | }
|
217 |
| - }) |
| 214 | + } |
218 | 215 | },
|
219 | 216 |
|
220 | 217 | beforeDestroy () {
|
|
0 commit comments