You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 24, 2023. It is now read-only.
@@ -14,60 +14,53 @@ More demos and examples coming soon in [vue-agile CodePens collection](https://c
14
14
15
15
If you like the component remember to **star it** ⭐️. If you appreciate my work you can also **[buy me a coffee](https://ko-fi.com/lukaszflorczak)** ☕️ 😉
16
16
17
-

18
-
19
17
---
20
18
21
19
🔭 If you're looking for Vue 2 version, check **[legacy/vue-v2](https://github.com/lukaszflorczak/vue-agile/tree/legacy/vue-v2)** branch.
22
20
23
-
---
24
-
25
-
## Important – update from version `1.0.x`
26
-
27
-
#### Events
28
-
*`afterChange` => `after-change`
29
-
*`beforeChange` => `before-change`
30
-
31
-
#### Deprecated
32
-
Deprecated props (`arrows`, `prevArrow`, `nextArrow`, `show`) and classes (`.agile__arrow`, `.agile__arrow--prev`, `.agile__arrow--next`, `.agile__slide--cloned`) from versions < `1.0` are no longer available
21
+

33
22
34
23
## Installation
35
24
36
25
```bash
37
26
npm install vue-agile
38
27
```
39
28
40
-
or
29
+
or
41
30
42
31
```bash
43
32
yarn add vue-agile
44
33
```
45
34
46
35
## Styles
47
36
48
-
**The component is delivered without styles for the appearance of the navigation elements** (like dots color and shape, arrows position, etc.). I think most people use their own styles and default styles are completely redundant. If you want, feel free to use styles from [CodePen demos](https://codepen.io/collection/AdRzJW/).
37
+
**The component is delivered without styles for the appearance of the navigation elements** (like dots color and shape, arrows position, etc.). I think most people use their own styles and default styles are completely redundant. If you
38
+
want, feel free to use styles from [CodePen demos](https://codepen.io/collection/AdRzJW/).
49
39
50
40
## Importing
51
41
52
42
#### Global
53
43
54
44
```js
55
45
// main.js
56
-
importVuefrom'vue'
46
+
import { createApp } from'vue'
47
+
importAppfrom'./App.vue'
57
48
importVueAgilefrom'vue-agile'
58
49
59
-
Vue.use(VueAgile)
50
+
createApp(App)
51
+
.use(VueAgile)
60
52
```
61
53
62
54
#### In component
55
+
63
56
```js
64
57
// YourComponent.vue
65
58
import { VueAgile } from'vue-agile'
66
59
67
-
exportdefault {
68
-
components: {
69
-
agile: VueAgile
70
-
}
60
+
exportdefault {
61
+
components: {
62
+
agile: VueAgile
63
+
}
71
64
}
72
65
```
73
66
@@ -82,23 +75,24 @@ export default {
82
75
83
76
```vue
84
77
<template>
85
-
<agile>
86
-
<div class="slide">
87
-
<h3>slide 1</h3>
88
-
</div>
89
-
90
-
...
91
-
92
-
<div class="slide">
93
-
<h3>slide n</h3>
94
-
</div>
95
-
</agile>
78
+
<agile>
79
+
<div class="slide">
80
+
<h3>slide 1</h3>
81
+
</div>
82
+
83
+
...
84
+
85
+
<div class="slide">
86
+
<h3>slide n</h3>
87
+
</div>
88
+
</agile>
96
89
</template>
97
90
```
98
91
99
92
Every first-level child of `<agile>` is a new slide. You also can group them inside `<template v-slot:default>...</template>` tags.
100
93
101
94
## Options / Props
95
+
102
96
| Parameter | Type | Default | Description |
103
97
| --- | :---: | :---: | --- |
104
98
|[asNavFor](#asNavFor)| array |`[]`| Set the carousel to be the navigation of other carousels |
@@ -168,9 +162,10 @@ Every first-level child of `<agile>` is a new slide. You also can group them ins
168
162
```
169
163
170
164
```js
171
-
showCurrentSlide (event) {
172
-
console.log(event)
173
-
// Shows for example: { currentSlide: 1 }
165
+
showCurrentSlide(event)
166
+
{
167
+
console.log(event)
168
+
// Shows for example: { currentSlide: 1 }
174
169
}
175
170
```
176
171
@@ -185,34 +180,35 @@ To customize responsiveness, I recommend defining your desired breakpoints and p
185
180
```
186
181
187
182
```js
188
-
data () {
189
-
return {
190
-
myOptions: {
191
-
navButtons:false,
192
-
193
-
responsive: [
194
-
{
195
-
breakpoint:600,
196
-
settings: {
197
-
dots:false
198
-
}
199
-
},
200
-
201
-
{
202
-
breakpoint:900,
203
-
settings: {
204
-
navButtons:true,
205
-
dots:true,
206
-
infinite:false
207
-
}
208
-
}
209
-
]
183
+
data()
184
+
{
185
+
return {
186
+
myOptions: {
187
+
navButtons:false,
188
+
responsive: [
189
+
{
190
+
breakpoint:600,
191
+
settings: {
192
+
dots:false
193
+
}
194
+
},
195
+
196
+
{
197
+
breakpoint:900,
198
+
settings: {
199
+
navButtons:true,
200
+
dots:true,
201
+
infinite:false
202
+
}
210
203
}
204
+
]
211
205
}
206
+
}
212
207
}
213
208
```
214
209
215
-
How does it work? Mobile first mode is used by default. It means, that `navButtons: false` option will be used on screens from 0 to 600 px width (+ all default carousel options). On screens from 600 to 900 px `dots: false` will be added to options from breakpoint before. And on screens over 900 px width `navButtons` and `dots` options will be overwritten and `infinite: false` will be added.
210
+
How does it work? Mobile first mode is used by default. It means, that `navButtons: false` option will be used on screens from 0 to 600 px width (+ all default carousel options). On screens from 600 to 900 px `dots: false` will be
211
+
added to options from breakpoint before. And on screens over 900 px width `navButtons` and `dots` options will be overwritten and `infinite: false` will be added.
216
212
217
213
## Custom arrows / nav buttons
218
214
@@ -222,10 +218,10 @@ From version `1.0` the component use slots for custom navigation buttons. It mea
222
218
223
219
```vue
224
220
<agile>
225
-
... <!-- slides -->
226
-
227
-
<template slot="prevButton">prev</template>
228
-
<template slot="nextButton">next</template>
221
+
... <!-- slides -->
222
+
223
+
<template slot="prevButton">prev</template>
224
+
<template slot="nextButton">next</template>
229
225
</agile>
230
226
```
231
227
@@ -237,30 +233,30 @@ To display a static caption or such like within the gallery, you can use the `ca
This option is useful for example for creating a photo gallery with two related slider –one big with only one slide in view and second for navigation with thumbnails.
259
+
This option is useful for example for creating a photo gallery with two related slider –one big with only one slide in view and second for navigation with thumbnails.
264
260
265
261
#### Example
266
262
@@ -274,11 +270,12 @@ This option is useful for example for creating a photo gallery with two related
274
270
275
271
## `v-if` & `v-show`
276
272
277
-
If you have slides being dynamically loaded, use `v-if` to show the carousel after the slides are ready. Using `v-if` is also recommended in other situations if you want to hide/show the slideshow.
273
+
If you have slides being dynamically loaded, use `v-if` to show the carousel after the slides are ready. Using `v-if` is also recommended in other situations if you want to hide/show the slideshow.
278
274
279
275
It is also possible to use `v-show`, but you have to use the `reload()` method.
@@ -288,7 +285,7 @@ It is also possible to use `v-show`, but you have to use the `reload()` method.
288
285
## Nuxt.js && SSR Support
289
286
290
287
The component uses browser specific attributes (like `window` and `document`). However, you can try to render the first view on server side.
291
-
288
+
292
289
#### Example
293
290
294
291
```js
@@ -304,61 +301,62 @@ Vue.use(VueAgile)
304
301
// nuxt.config.js
305
302
306
303
exportdefault {
307
-
plugins: ['~/plugins/vue-agile'],
304
+
plugins: ['~/plugins/vue-agile'],
308
305
309
-
build: {
310
-
transpile: ['vue-agile']
311
-
}
306
+
build: {
307
+
transpile: ['vue-agile']
308
+
}
312
309
}
313
310
```
314
311
315
312
To use component without SSR use the `client-only` component:
316
313
317
314
```vue
318
315
<client-only placeholder="Loading...">
319
-
<agile>...</agile>
316
+
<agile>...</agile>
320
317
</client-only>
321
318
```
322
319
323
-
**Important!** Component rendered on server side has additional CSS class: `agile--ssr`, so you can use it to add some additional styles or manipulations. For example, I have limited options for setting the first appearance of the slides. By default, the server renders the view and styles, where only the first slide is visible.
320
+
**Important!** Component rendered on server side has additional CSS class: `agile--ssr`, so you can use it to add some additional styles or manipulations. For example, I have limited options for setting the first appearance of the slides.
321
+
By default, the server renders the view and styles, where only the first slide is visible.
324
322
325
323
```css
326
324
.agile--ssr.agile__slides>* {
327
-
overflow: hidden;
328
-
width: 0
325
+
overflow: hidden;
326
+
width: 0
329
327
}
330
328
331
329
.agile--ssr.agile__slides>*:first-child {
332
-
width: 100%
330
+
width: 100%
333
331
}
334
332
```
335
333
336
-
At this stage slides don't have `agile__slide` class yet, so I use `> *` instead of this.
334
+
At this stage slides don't have `agile__slide` class yet, so I use `> *` instead of this.
337
335
338
-
If you would like to connect this with params `slidesToShow` or `initialSlide` you have to add some custom styles with `nth-child` param.
336
+
If you would like to connect this with params `slidesToShow` or `initialSlide` you have to add some custom styles with `nth-child` param.
339
337
340
338
#### Example for `:slidesToShow="2"`
341
339
342
340
```sass
343
-
.agile--ssr
344
-
.agile__slides
345
-
> *:nth-child(1),
346
-
> *:nth-child(2)
347
-
width: 50%
341
+
.agile--ssr
342
+
.agile__slides
343
+
> *:nth-child(1),
344
+
> *:nth-child(2)
345
+
width: 50%
348
346
```
349
347
350
348
#### Example for `:initialSlide="1"`
351
349
352
350
(Slides index starts at `0`)
353
351
354
352
```sass
355
-
.agile--ssr
356
-
.agile__slides
357
-
> *:nth-child(1)
358
-
width: 0
353
+
.agile--ssr
354
+
.agile__slides
355
+
> *:nth-child(1)
356
+
width: 0
359
357
360
-
> *:nth-child(2)
361
-
width: 100%
358
+
> *:nth-child(2)
359
+
width: 100%
362
360
```
363
361
364
362
You can also check [nuxt-agile](https://github.com/lukaszflorczak/nuxt-agile) repository and check working demo of vue-agile with Nuxt and SSR.
0 commit comments