Skip to content

Commit 21f2c9a

Browse files
committed
build: build 2.0.0-alpha.23
1 parent 9980f5c commit 21f2c9a

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

docs/2.0.0/carousel.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
<za-carousel
4848
ref="carousel"
4949
direction="left"
50+
:swipeable="false"
5051
loop
5152
@changeStart="handleChangeStart"
5253
@changeEnd="handleChangeEnd"
@@ -72,7 +73,7 @@
7273
:::demo 自动轮播
7374

7475
```html
75-
<za-carousel direction="left" loop auto-play>
76+
<za-carousel direction="left" :swipeable="false" loop auto-play>
7677
<za-carousel-item :key="index" v-for="(i, index) in ITEMS">
7778
<div class="carousel-item-pic">
7879
<img :src="i.url" :alt="i.img" :draggable="false" />
@@ -136,7 +137,8 @@ export default {
136137
| direction | string | 'left' | 'left', 'right', 'top', 'bottom' | 滑动方向 |
137138
| height | number, string | | | 高度 |
138139
| loop | boolean | false | | 是否循环 |
139-
| active-ndex | number | 0 | | 当前页面的索引 |
140+
| active-index | number | 0 | | 当前页面的索引 |
141+
| swipeable | boolean | true | | 是否可拖拽 |
140142
| auto-play | boolean | false | | 是否自动轮播 |
141143
| auto-play-interval-time | number | 3000 | | 自动轮播时间间隔,单位:毫秒 |
142144
| move-distance-ratio | number | 0.5 | | 移动距离比例临界点 |

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zarm-vue",
3-
"version": "2.0.0-alpha.22",
3+
"version": "2.0.0-alpha.23",
44
"description": "zarm in vue",
55
"tags": [
66
"zarm",

src/carousel/src/carousel.vue

+12
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ export default {
3535
type: Number,
3636
default: 300,
3737
},
38+
swipeable: {
39+
type: Boolean,
40+
default: true,
41+
},
3842
autoPlay: {
3943
type: Boolean,
4044
default: false,
@@ -106,6 +110,8 @@ export default {
106110
},
107111
methods: {
108112
onDragStart() {
113+
// 如果禁用滑动,屏蔽drag行为
114+
if (!this.swipeable) return;
109115
this.scrolling = false;
110116
// 如果正好在transition动画中,跳转到头尾
111117
const activeIndex = this.currentActiveIndex;
@@ -120,6 +126,9 @@ export default {
120126
this.pauseAutoPlay();
121127
},
122128
onDragMove(event, { offsetX, offsetY }) {
129+
// 如果禁用滑动,屏蔽drag行为
130+
if (!this.swipeable) return;
131+
123132
const distanceX = Math.abs(offsetX);
124133
const distanceY = Math.abs(offsetY);
125134
@@ -158,6 +167,9 @@ export default {
158167
},
159168
160169
onDragEnd(event, { offsetX, offsetY, startTime }) { // eslint-disable-line no-unused-vars
170+
// 如果禁用滑动,屏蔽drag行为
171+
if (!this.swipeable) return;
172+
161173
if (this.scrolling ||
162174
(!offsetX && !offsetY)
163175
) {

0 commit comments

Comments
 (0)