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

Commit f48cde2

Browse files
author
Łukasz Florczak
committed
initialSlide support (resolve #33)
1 parent 165335e commit f48cde2

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ Every first-level child of `<agile>` is a new slide.
6464
| dots | boolean | `true` | Enable dot indicators/pagination |
6565
| fade | boolean | `false` | Enable fade effect |
6666
| infinite | boolean | `true` | Infinite loop sliding |
67+
| initialSlide | integer | Slide to start on (numbered from zero) |
6768
| mobileFirst | boolean | `true` | Enable mobile first calculation for responsive settings |
6869
| options | object | `null` | All settings as one object |
6970
| pauseOnHover | boolean | `true` | Pause autoplay when a slide is hovered |

src/Agile.vue

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
default: true
7171
},
7272
73+
initialSlide: {
74+
type: Number,
75+
default: 0
76+
},
77+
7378
mobileFirst: {
7479
type: Boolean,
7580
default: true
@@ -147,7 +152,7 @@
147152
autoplayStatus: false,
148153
autoplayTimeout: null,
149154
allSlidesCount: 0,
150-
currentSlide: 0,
155+
currentSlide: null,
151156
mouseDown: false,
152157
dragStartX: 0,
153158
dragStaryY: 0,
@@ -162,16 +167,17 @@
162167
track: 0
163168
},
164169
defaultSettings: {
165-
prevArrow: this.prevArrow,
166-
nextArrow: this.nextArrow,
167170
arrows: this.arrows,
168171
autoplay: this.autoplay,
169172
autoplaySpeed: this.autoplaySpeed,
170173
dots: this.dots,
171174
fade: this.fade,
172175
infinite: this.infinite,
176+
initialSlide: this.initialSlide,
177+
nextArrow: this.nextArrow,
173178
pauseOnDotsHover: this.pauseOnDotsHover,
174179
pauseOnHover: this.pauseOnHover,
180+
prevArrow: this.prevArrow,
175181
responsive: this.responsive,
176182
slidesToScroll: this.slidesToScroll,
177183
slidesToShow: this.slidesToShow,
@@ -576,6 +582,11 @@
576582
this.transform = 0
577583
} else {
578584
this.width.track = this.width.slide * this.allSlidesCount
585+
586+
if (this.currentSlide === null) {
587+
this.currentSlide = this.settings.initialSlide
588+
}
589+
579590
this.goTo(this.currentSlide, false, false)
580591
}
581592
},

0 commit comments

Comments
 (0)