1
1
import observeDom from '../../utils/observe-dom'
2
2
import KeyCodes from '../../utils/key-codes'
3
+ import noop from '../../utils/noop'
3
4
import {
4
5
selectAll ,
5
6
reflow ,
@@ -28,7 +29,7 @@ const DIRECTION = {
28
29
const TRANS_DURATION = 600 + 50
29
30
30
31
// Time for mouse compat events to fire after touch
31
- const TOUCHEVENT_COMPAT_WAIT = 500
32
+ const TOUCH_EVENT_COMPAT_WAIT = 500
32
33
33
34
// Number of pixels to consider touch move a swipe
34
35
const SWIPE_THRESHOLD = 40
@@ -50,7 +51,7 @@ const TransitionEndEvents = {
50
51
const EventOptions = { passive : true , capture : false }
51
52
52
53
// Return the browser specific transitionEnd event name
53
- function getTransisionEndEvent ( el ) {
54
+ function getTransitionEndEvent ( el ) {
54
55
for ( const name in TransitionEndEvents ) {
55
56
if ( el . style [ name ] !== undefined ) {
56
57
return TransitionEndEvents [ name ]
@@ -61,8 +62,6 @@ function getTransisionEndEvent(el) {
61
62
return null
62
63
}
63
64
64
- const noop = ( ) => { }
65
-
66
65
// @vue /component
67
66
export default {
68
67
name : 'BCarousel' ,
@@ -194,7 +193,7 @@ export default {
194
193
} ,
195
194
mounted ( ) {
196
195
// Cache current browser transitionend event name
197
- this . transitionEndEvent = getTransisionEndEvent ( this . $el ) || null
196
+ this . transitionEndEvent = getTransitionEndEvent ( this . $el ) || null
198
197
// Get all slides
199
198
this . updateSlides ( )
200
199
// Observe child changes so we can update slide list
@@ -205,7 +204,7 @@ export default {
205
204
attributeFilter : [ 'id' ]
206
205
} )
207
206
} ,
208
- beforeDestroy ( ) /* istanbul ignore next: dificult to test */ {
207
+ beforeDestroy ( ) /* istanbul ignore next: difficult to test */ {
209
208
clearTimeout ( this . _animationTimeout )
210
209
clearTimeout ( this . _touchTimeout )
211
210
clearInterval ( this . _intervalId )
@@ -217,7 +216,7 @@ export default {
217
216
// Set slide
218
217
setSlide ( slide , direction = null ) {
219
218
// Don't animate when page is not visible
220
- /* istanbul ignore if: dificult to test */
219
+ /* istanbul ignore if: difficult to test */
221
220
if ( inBrowser && document . visibilityState && document . hidden ) {
222
221
return
223
222
}
@@ -261,7 +260,7 @@ export default {
261
260
if ( ! evt ) {
262
261
this . isPaused = false
263
262
}
264
- /* istanbul ignore next: most likley will never happen, but just in case */
263
+ /* istanbul ignore next: most likely will never happen, but just in case */
265
264
if ( this . _intervalId ) {
266
265
clearInterval ( this . _intervalId )
267
266
this . _intervalId = null
@@ -271,9 +270,9 @@ export default {
271
270
this . _intervalId = setInterval ( this . next , Math . max ( 1000 , this . interval ) )
272
271
}
273
272
} ,
274
- // Re-Start auto rotate slides when focus/hover leaves the carousel
273
+ // Restart auto rotate slides when focus/hover leaves the carousel
275
274
restart ( evt ) {
276
- /* istanbul ignore if: dificult to test */
275
+ /* istanbul ignore if: difficult to test */
277
276
if ( ! this . $el . contains ( document . activeElement ) ) {
278
277
this . start ( )
279
278
}
@@ -314,7 +313,7 @@ export default {
314
313
addClass ( nextSlide , dirClass )
315
314
// Transition End handler
316
315
let called = false
317
- /* istanbul ignore next: dificult to test */
316
+ /* istanbul ignore next: difficult to test */
318
317
const onceTransEnd = evt => {
319
318
if ( called ) {
320
319
return
@@ -347,7 +346,7 @@ export default {
347
346
const events = this . transitionEndEvent . split ( / \s + / )
348
347
events . forEach ( event => eventOn ( currentSlide , event , onceTransEnd , EventOptions ) )
349
348
}
350
- // Fallback to setTimeout
349
+ // Fallback to setTimeout()
351
350
this . _animationTimeout = setTimeout ( onceTransEnd , TRANS_DURATION )
352
351
}
353
352
if ( isCycling ) {
@@ -393,16 +392,16 @@ export default {
393
392
}
394
393
} ,
395
394
handleSwipe ( ) /* istanbul ignore next: JSDOM doesn't support touch events */ {
396
- const absDeltax = Math . abs ( this . touchDeltaX )
397
- if ( absDeltax <= SWIPE_THRESHOLD ) {
395
+ const absDeltaX = Math . abs ( this . touchDeltaX )
396
+ if ( absDeltaX <= SWIPE_THRESHOLD ) {
398
397
return
399
398
}
400
- const direction = absDeltax / this . touchDeltaX
399
+ const direction = absDeltaX / this . touchDeltaX
401
400
if ( direction > 0 ) {
402
- // swipe left
401
+ // Swipe left
403
402
this . prev ( )
404
403
} else if ( direction < 0 ) {
405
- // swipe right
404
+ // Swipe right
406
405
this . next ( )
407
406
}
408
407
} ,
@@ -414,7 +413,7 @@ export default {
414
413
}
415
414
} ,
416
415
touchMove ( evt ) /* istanbul ignore next: JSDOM doesn't support touch events */ {
417
- // ensure swiping with one touch and not pinching
416
+ // Ensure swiping with one touch and not pinching
418
417
if ( evt . touches && evt . touches . length > 1 ) {
419
418
this . touchDeltaX = 0
420
419
} else {
@@ -439,7 +438,7 @@ export default {
439
438
}
440
439
this . _touchTimeout = setTimeout (
441
440
this . start ,
442
- TOUCHEVENT_COMPAT_WAIT + Math . max ( 1000 , this . interval )
441
+ TOUCH_EVENT_COMPAT_WAIT + Math . max ( 1000 , this . interval )
443
442
)
444
443
}
445
444
} ,
@@ -458,7 +457,7 @@ export default {
458
457
[ this . $slots . default ]
459
458
)
460
459
461
- // Prev and Next Controls
460
+ // Prev and next controls
462
461
let controls = h ( false )
463
462
if ( this . controls ) {
464
463
controls = [
@@ -567,7 +566,8 @@ export default {
567
566
}
568
567
// Touch support event handlers for environment
569
568
if ( ! this . noTouch && hasTouchSupport ) {
570
- /* istanbul ignore next: JSDOM doesn't support touch events */ // Attach appropriate listeners (passsive mode)
569
+ // Attach appropriate listeners (passive mode)
570
+ /* istanbul ignore next: JSDOM doesn't support touch events */
571
571
if ( hasPointerEvent ) {
572
572
on [ '&pointerdown' ] = this . touchStart
573
573
on [ '&pointerup' ] = this . touchEnd
0 commit comments