Skip to content

Commit 7593846

Browse files
Merge branch 'v0.17.0' into feat-fix-aria
2 parents b7146db + 7d5cb5c commit 7593846

File tree

14 files changed

+721
-357
lines changed

14 files changed

+721
-357
lines changed

.lintstagedrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"linters": {
3+
"src/**/?(*.js|*.vue)": [
4+
"prettier-eslint --write",
5+
"git add"
6+
]
7+
}
8+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ export default {
8080
| navigationPrevLabel | String || Text content of the navigation prev button. |
8181
| paginationActiveColor | String | #000000 | The fill color of the active pagination dot. Any valid CSS color is accepted. |
8282
| paginationColor | String | #efefef | The fill color of pagination dots. Any valid CSS color is accepted. |
83+
| paginationPosition | String | bottom | The position of pagination dots. Possible values are `bottom`, `bottom-overlay`, `top` and `top-overlay`. The overlay values place the pagination component over the images. |
8384
| paginationEnabled | Boolean | true | Flag to render pagination component. |
8485
| paginationPadding | Number | 10 | The padding inside each pagination dot. Pixel values are accepted. |
8586
| paginationSize | Number | 10 | The size of each pagination dot. Pixel values are accepted. |

dist/vue-carousel.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/source/api/index.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,13 @@ The fill color of pagination dots. Any valid CSS color is accepted.
221221
* **Type**: `String`
222222
* **Default**: `#efefef`
223223

224+
### paginationPosition
225+
226+
The position of pagination dots. Possible values are `bottom`, `bottom-overlay`, `top` and `top-overlay`. The overlay values place the pagination component over the images.
227+
228+
* **Type**: `String`
229+
* **Default**: `bottom`
230+
224231
### paginationPadding
225232

226233
The padding inside each pagination dot. Pixel values are accepted.

docs/themes/vue/source/js/vue-carousel.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue-carousel",
3-
"version": "0.16.1",
3+
"version": "0.16.2",
44
"description": "A flexible, responsive, touch-friendly carousel for Vue.js",
55
"main": "dist/vue-carousel.min.js",
66
"scripts": {
@@ -10,10 +10,10 @@
1010
"dev:build": "vue-play build",
1111
"docs:build": "npm run build && rm -rf ./docs/public && mkdir ./docs/public/ && cd ./docs/public/ && git init && git remote add origin [email protected]:SSENSE/vue-carousel.git && git fetch && git checkout -f gh-pages && cd .. && npm install && ./node_modules/.bin/hexo clean && ./node_modules/.bin/hexo generate",
1212
"lint": "prettier-eslint --write \"src/**/?(*.js|*.vue)\" || exit 1",
13-
"precommit": "npm run lint && npm run test",
13+
"precommit": "lint-staged && npm run test",
1414
"test": "npm run test:client",
15-
"test:client": "jest --config tests/client.jest.json --forceExit",
16-
"test:client:coverage": "jest --config tests/client.jest.json --coverage --forceExit",
15+
"test:client": "jest --config tests/client.jest.json",
16+
"test:client:coverage": "jest --config tests/client.jest.json --coverage",
1717
"test-coverage": "npm run test:client:coverage",
1818
"updateDocAssets": "cp ./dist/vue-carousel.min.js ./docs/themes/vue/source/js/"
1919
},
@@ -43,8 +43,8 @@
4343
"@babel/core": "^7.0.0",
4444
"@babel/polyfill": "^7.0.0",
4545
"@babel/preset-env": "^7.0.0",
46+
"@vue/test-utils": "^1.0.0-beta.26",
4647
"babel-loader": "^8.0.1",
47-
"chai": "^3.5.0",
4848
"coveralls": "^3.0.1",
4949
"css-loader": "^1.0.0",
5050
"eslint": "^3.19.0",
@@ -62,13 +62,11 @@
6262
"isparta": "^4.0.0",
6363
"isparta-loader": "^2.0.0",
6464
"jest": "^23.5.0",
65-
"mocha": "^5.2.0",
65+
"lint-staged": "^8.1.0",
6666
"prettier": "^1.10.2",
6767
"prettier-eslint": "^8.8.1",
6868
"prettier-eslint-cli": "^4.7.0",
6969
"shelljs": "^0.7.5",
70-
"sinon": "^1.17.6",
71-
"sinon-chai": "^2.8.0",
7270
"uglifyjs-webpack-plugin": "^1.3.0",
7371
"vue-loader": "^15.3.0",
7472
"vue-play-cli": "^1.1.1",

play/index.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,35 @@ play("Carousel", module)
102102
h, containerWidth, [h(Carousel, { props: { autoplay: true, autoplayHoverPause: true } }, generateSlideImages(h))]
103103
)
104104
)
105+
.add("Autoplay, Pause/Resume", {
106+
template:
107+
`<div style="width: 100%; display: flex; justify-content: center; margin-top: 40px;">
108+
<carousel style="width: 500px;" :autoplay="autoplay" :loop="true">
109+
<slide v-for="slide in slideCount" :key="slide">
110+
<img style="width: 100%;" src="https://res.cloudinary.com/ssenseweb/image/upload/b_white,c_lpad,g_south,h_1086,w_724/c_scale,h_560/v588/171924M176006_1.jpg" />
111+
</slide>
112+
</carousel>
113+
<div style="float: left">
114+
<pre>Autoplay Status: {{ autoplay }}</pre>
115+
<button v-on:click="toggleAutoplay()">Toggle Autoplay</button>
116+
</div>
117+
</div>`,
118+
components: {
119+
Carousel,
120+
Slide
121+
},
122+
data() {
123+
return {
124+
autoplay: true,
125+
slideCount: 8
126+
}
127+
},
128+
methods: {
129+
toggleAutoplay() {
130+
this.autoplay = !this.autoplay;
131+
},
132+
}
133+
})
105134
.add("Dynamic, add or remove slides", {
106135
template:
107136
`<div style="width: 100%; display: flex; justify-content: center; margin-top: 40px;">
@@ -374,3 +403,12 @@ play("Carousel", module)
374403
}
375404
}
376405
})
406+
.add("Pagination position top", h => createContainer(
407+
h, containerWidth, [h(Carousel, { props: { paginationPosition: 'top' } }, generateSlideImages(h))]
408+
))
409+
.add("Pagination position top-overlay", h => createContainer(
410+
h, containerWidth, [h(Carousel, { props: { paginationPosition: 'top-overlay' } }, generateSlideImages(h))]
411+
))
412+
.add("Pagination position bottom-overlay", h => createContainer(
413+
h, containerWidth, [h(Carousel, { props: { paginationPosition: 'bottom-overlay' } }, generateSlideImages(h))]
414+
))

src/Carousel.vue

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<section class="VueCarousel">
2+
<section
3+
class="VueCarousel"
4+
v-bind:class="{ 'VueCarousel--reverse': paginationPosition === 'top' }"
5+
>
36
<div
47
class="VueCarousel-wrapper"
58
ref="VueCarousel-wrapper"
@@ -163,7 +166,7 @@ export default {
163166
type: Boolean,
164167
default: true
165168
},
166-
/*
169+
/**
167170
* Flag to toggle touch dragging
168171
*/
169172
touchDrag: {
@@ -237,6 +240,14 @@ export default {
237240
type: Number,
238241
default: 10
239242
},
243+
/**
244+
* Configure the position for the pagination component.
245+
* The possible values are: 'bottom', 'top', 'bottom-overlay' and 'top-overlay'
246+
*/
247+
paginationPosition: {
248+
type: String,
249+
default: "bottom"
250+
},
240251
/**
241252
* The size of each pagination dot
242253
* Pixel values are accepted
@@ -340,6 +351,13 @@ export default {
340351
currentPage(val) {
341352
this.$emit("pageChange", val);
342353
this.$emit("input", val);
354+
},
355+
autoplay(val) {
356+
if (val === false) {
357+
this.pauseAutoplay();
358+
} else {
359+
this.restartAutoplay();
360+
}
343361
}
344362
},
345363
computed: {
@@ -880,9 +898,15 @@ export default {
880898
</script>
881899
<style>
882900
.VueCarousel {
901+
display: flex;
902+
flex-direction: column;
883903
position: relative;
884904
}
885905
906+
.VueCarousel--reverse {
907+
flex-direction: column-reverse;
908+
}
909+
886910
.VueCarousel-wrapper {
887911
width: 100%;
888912
position: relative;

src/Pagination.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ export default {
2929
name: "pagination",
3030
inject: ["carousel"],
3131
computed: {
32+
paginationPositionModifierName() {
33+
const { paginationPosition } = this.carousel;
34+
// guard to add only required class modifiers
35+
if (paginationPosition.indexOf("overlay") < 0) return;
36+
return paginationPosition;
37+
},
38+
paginationPropertyBasedOnPosition() {
39+
return this.carousel.paginationPosition.indexOf("top") >= 0
40+
? "bottom"
41+
: "top";
42+
},
3243
paginationCount() {
3344
return this.carousel && this.carousel.scrollPerPage
3445
? this.carousel.pageCount
@@ -69,6 +80,16 @@ export default {
6980
text-align: center;
7081
}
7182
83+
.VueCarousel-pagination--top-overlay {
84+
position: absolute;
85+
top: 0;
86+
}
87+
88+
.VueCarousel-pagination--bottom-overlay {
89+
position: absolute;
90+
bottom: 0;
91+
}
92+
7293
.VueCarousel-dot-container {
7394
display: inline-block;
7495
margin: 0 auto;

tests/client.jest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"verbose": true,
3+
"rootDir": "../",
34
"transform": {
4-
".*\\.(js|vue)$": "<rootDir>/preprocessor.js"
5+
".*\\.(js|vue)$": "<rootDir>/tests/preprocessor.js"
56
},
67
"testPathIgnorePatterns": [
78
"/node_modules/",

0 commit comments

Comments
 (0)