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

Commit d4102f0

Browse files
author
Łukasz Florczak
committed
Unagile option
1 parent fde7ebf commit d4102f0

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

src/Agile.vue

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<div class="agile" :class="{'agile--fade': settings.fade}">
2+
<div class="agile"
3+
:class="{'agile--fade': settings.fade && !settings.unagile, 'agile--disabled': settings.unagile}">
34
<div ref="list" class="agile__list">
45
<div ref="track" class="agile__track"
56
:style="{width: width.track + 'px', transform: 'translate(-' + transform + 'px)', transition: 'transform ' + settings.timing + ' ' + transitionDelay + 'ms'}"
@@ -228,7 +229,7 @@
228229
getWidth () {
229230
this.width = {
230231
document: window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth,
231-
container: !this.settings.unagile ? this.$refs.list.clientWidth : 'auto',
232+
container: this.$refs.list.clientWidth,
232233
slide: !this.settings.unagile ? this.$refs.list.clientWidth / this.slidesToShow : 'auto'
233234
}
234235
},
@@ -325,7 +326,7 @@
325326
},
326327
327328
countSlides () {
328-
if (this.settings.infinite && !this.settings.fade) {
329+
if (this.settings.infinite && !this.settings.fade && !this.settings.unagile) {
329330
this.allSlidesCount = this.slidesCount + 2
330331
} else {
331332
this.allSlidesCount = this.slidesCount
@@ -365,6 +366,10 @@
365366
},
366367
367368
setSlide (n, transition = true, autoplayTimeout = true) {
369+
if (this.settings.unagile) {
370+
return false
371+
}
372+
368373
// Reset autoplay timeout and set new
369374
if (this.settings.autoplay && autoplayTimeout) {
370375
this.stopAutoplay()
@@ -480,7 +485,7 @@
480485
}
481486
482487
// Check infinity mode status and enable/disable
483-
if (this.settings.infinite && !this.settings.fade) {
488+
if (this.settings.infinite && !this.settings.fade && !this.settings.unagile) {
484489
this.enableInfiniteMode()
485490
} else {
486491
this.disableInfiniteMode()
@@ -491,7 +496,7 @@
491496
this.enableAutoplayMode()
492497
}
493498
494-
if (!this.settings.autoplay && this.autoplayStatus) {
499+
if ((!this.settings.autoplay && this.autoplayStatus) || this.settings.unagile) {
495500
this.disableAutoplayMode()
496501
}
497502
@@ -500,23 +505,24 @@
500505
this.slides[i].style.width = this.width.container + 'px'
501506
502507
// Prepare slides for fade mode
503-
if (this.settings.fade) {
508+
if (this.settings.fade && !this.settings.unagile) {
504509
this.slides[i].style.transform = 'translate(-' + i * this.width.slide + 'px)'
505510
} else {
506511
this.slides[i].style.transform = 'translate(0)'
507512
}
508513
}
509514
510515
// Prepare track
511-
this.width.track = this.width.container * this.allSlidesCount
512-
this.setSlide(this.currentSlide, false, false)
516+
if (this.settings.unagile) {
517+
this.width.track = this.width.container
518+
this.transform = 0
519+
} else {
520+
this.width.track = this.width.container * this.allSlidesCount
521+
this.setSlide(this.currentSlide, false, false)
522+
}
513523
},
514524
515525
dragDistance () {
516-
if (!this.mouseDown) {
517-
return
518-
}
519-
520526
if (this.dragDistance > this.swipeDistance) {
521527
if (!this.settings.infinite && this.currentSlide === 0) {
522528
return
@@ -562,6 +568,10 @@
562568
align-items: center;
563569
display: flex;
564570
justify-content: flex-start;
571+
572+
.agile--disabled & {
573+
display: block;
574+
}
565575
}
566576
567577
&__slide {

0 commit comments

Comments
 (0)