@@ -277,13 +277,13 @@ export default {
277
277
} ,
278
278
// Previous slide
279
279
prev ( ) {
280
+ this . direction = 'prev'
280
281
this . setSlide ( this . index - 1 )
281
- this . direction = DIRECTION . prev
282
282
} ,
283
283
// Next slide
284
284
next ( ) {
285
+ this . direction = 'next'
285
286
this . setSlide ( this . index + 1 )
286
- this . direction = DIRECTION . next
287
287
} ,
288
288
// Pause auto rotation
289
289
pause ( ) {
@@ -298,7 +298,7 @@ export default {
298
298
} ,
299
299
// Start auto rotate slides
300
300
start ( ) {
301
- // Don't start if no intetrval , or if we are already running
301
+ // Don't start if no interval , or if we are already running
302
302
if ( ! this . interval || this . isCycling ) {
303
303
return
304
304
}
@@ -338,6 +338,12 @@ export default {
338
338
// Set slide as active
339
339
this . setSlide ( index )
340
340
this . start ( )
341
+ } ,
342
+ calcDirection ( direction = null , curIndex = 0 , nextIndex = 0 ) {
343
+ if ( ! direction ) {
344
+ return ( nextIndex > curIndex ) ? DIRECTION . next : DIRECTION . prev
345
+ }
346
+ return DIRECTION [ direction ]
341
347
}
342
348
} ,
343
349
watch : {
@@ -363,7 +369,8 @@ export default {
363
369
if ( val === oldVal || this . isSliding ) {
364
370
return
365
371
}
366
-
372
+ // Determine sliding direction
373
+ let direction = this . calcDirection ( this . direction , oldVal , val )
367
374
// Determine current and next slides
368
375
const currentSlide = this . slides [ oldVal ]
369
376
const nextSlide = this . slides [ val ]
@@ -376,11 +383,11 @@ export default {
376
383
this . $emit ( 'sliding-start' , val )
377
384
// Update v-model
378
385
this . $emit ( 'input' , this . index )
379
- nextSlide . classList . add ( this . direction . overlayClass )
386
+ nextSlide . classList . add ( direction . overlayClass )
380
387
// Trigger a reflow of next slide
381
388
reflow ( nextSlide )
382
- addClass ( currentSlide , this . direction . dirClass )
383
- addClass ( nextSlide , this . direction . dirClass )
389
+ addClass ( currentSlide , direction . dirClass )
390
+ addClass ( nextSlide , direction . dirClass )
384
391
// Transition End handler
385
392
let called = false
386
393
/* istanbul ignore next: dificult to test */
@@ -396,12 +403,12 @@ export default {
396
403
} )
397
404
}
398
405
this . _animationTimeout = null
399
- removeClass ( nextSlide , this . direction . dirClass )
400
- removeClass ( nextSlide , this . direction . overlayClass )
406
+ removeClass ( nextSlide , direction . dirClass )
407
+ removeClass ( nextSlide , direction . overlayClass )
401
408
addClass ( nextSlide , 'active' )
402
409
removeClass ( currentSlide , 'active' )
403
- removeClass ( currentSlide , this . direction . dirClass )
404
- removeClass ( currentSlide , this . direction . overlayClass )
410
+ removeClass ( currentSlide , direction . dirClass )
411
+ removeClass ( currentSlide , direction . overlayClass )
405
412
setAttr ( currentSlide , 'aria-current' , 'false' )
406
413
setAttr ( nextSlide , 'aria-current' , 'true' )
407
414
setAttr ( currentSlide , 'aria-hidden' , 'true' )
@@ -416,6 +423,7 @@ export default {
416
423
} )
417
424
}
418
425
this . isSliding = false
426
+ this . direction = null
419
427
// Notify ourselves that we're done sliding (slid)
420
428
this . $nextTick ( ( ) => this . $emit ( 'sliding-end' , val ) )
421
429
}
0 commit comments