@mixd-id/web-scaffold 0.1.230406206 → 0.1.230406208
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/components/Carousel.vue +25 -38
package/package.json
CHANGED
|
@@ -102,14 +102,20 @@ export default{
|
|
|
102
102
|
index: 0,
|
|
103
103
|
timeoutId: null,
|
|
104
104
|
scrollPosition: null,
|
|
105
|
+
swiping: false,
|
|
105
106
|
}
|
|
106
107
|
},
|
|
107
108
|
|
|
108
109
|
mounted(){
|
|
110
|
+
window.addEventListener('touchmove', this.onTouchMove, { passive: false });
|
|
109
111
|
if(this.autoPlay > 0)
|
|
110
112
|
this.play()
|
|
111
113
|
},
|
|
112
114
|
|
|
115
|
+
unmounted() {
|
|
116
|
+
window.removeEventListener('touchmove', this.onTouchMove, { passive: false });
|
|
117
|
+
},
|
|
118
|
+
|
|
113
119
|
watch:{
|
|
114
120
|
|
|
115
121
|
index(to){
|
|
@@ -125,6 +131,14 @@ export default{
|
|
|
125
131
|
|
|
126
132
|
methods:{
|
|
127
133
|
|
|
134
|
+
onTouchMove(e){
|
|
135
|
+
if(this.swiping && e.cancelable) {
|
|
136
|
+
e.preventDefault();
|
|
137
|
+
e.returnValue = false;
|
|
138
|
+
return false;
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
|
|
128
142
|
setPosition(noAnimation) {
|
|
129
143
|
if(!this.$refs.inner) return
|
|
130
144
|
|
|
@@ -202,7 +216,6 @@ export default{
|
|
|
202
216
|
const sy = typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY
|
|
203
217
|
const dx = sx - this._props['sx']
|
|
204
218
|
const dy = sy - this._props['sy']
|
|
205
|
-
const ix = parseInt(this._props['ix'] + dx)
|
|
206
219
|
|
|
207
220
|
if(!this._props['direction']){
|
|
208
221
|
if(Math.abs(dy) > 3){
|
|
@@ -210,10 +223,19 @@ export default{
|
|
|
210
223
|
}
|
|
211
224
|
else if(Math.abs(dx) > 3){
|
|
212
225
|
this._props['direction'] = 'horizontal'
|
|
213
|
-
this.
|
|
226
|
+
this.swiping = true
|
|
214
227
|
}
|
|
215
228
|
}
|
|
216
229
|
else if(this._props['direction'] === 'horizontal'){
|
|
230
|
+
let ix
|
|
231
|
+
if((this.index === this.items.length - 1 && dx < 0) ||
|
|
232
|
+
(this.index === 0 && dx > 0)){
|
|
233
|
+
ix = parseInt(this._props['ix'] + (dx * .23812))
|
|
234
|
+
}
|
|
235
|
+
else{
|
|
236
|
+
ix = parseInt(this._props['ix'] + dx)
|
|
237
|
+
}
|
|
238
|
+
|
|
217
239
|
this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
|
|
218
240
|
}
|
|
219
241
|
|
|
@@ -237,7 +259,7 @@ export default{
|
|
|
237
259
|
this.setPosition()
|
|
238
260
|
}
|
|
239
261
|
|
|
240
|
-
this.
|
|
262
|
+
this.swiping = false
|
|
241
263
|
}
|
|
242
264
|
|
|
243
265
|
window.removeEventListener('mousemove', this.mouseMove)
|
|
@@ -250,24 +272,6 @@ export default{
|
|
|
250
272
|
this.play()
|
|
251
273
|
},
|
|
252
274
|
|
|
253
|
-
disableBodyScroll(){
|
|
254
|
-
if(this.$isTouchSupported()){
|
|
255
|
-
this.scrollPosition = window.pageYOffset || document.documentElement.offsetTop
|
|
256
|
-
document.body.classList.add(this.$style.htmlNoScroll)
|
|
257
|
-
document.body.classList.add(this.$style.bodyNoScroll)
|
|
258
|
-
document.body.style.top = `-${this.scrollPosition}px`;
|
|
259
|
-
}
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
enableBodyScroll(){
|
|
263
|
-
if(this.$isTouchSupported()){
|
|
264
|
-
document.body.style.removeProperty('top');
|
|
265
|
-
document.body.classList.remove(this.$style.bodyNoScroll)
|
|
266
|
-
document.body.classList.remove(this.$style.htmlNoScroll)
|
|
267
|
-
window.scrollTo(0, this.scrollPosition);
|
|
268
|
-
}
|
|
269
|
-
},
|
|
270
|
-
|
|
271
275
|
mouseDown(e){
|
|
272
276
|
if(!this.items || this.items.length <= 1)
|
|
273
277
|
return
|
|
@@ -364,22 +368,5 @@ export default{
|
|
|
364
368
|
@apply bg-primary-500;
|
|
365
369
|
}
|
|
366
370
|
|
|
367
|
-
.htmlNoScroll{
|
|
368
|
-
min-height: 100.3%;
|
|
369
|
-
overscroll-behavior-y: none;
|
|
370
|
-
height: 100%;
|
|
371
|
-
overflow: hidden;
|
|
372
|
-
}
|
|
373
|
-
.bodyNoScroll{
|
|
374
|
-
overscroll-behavior: none;
|
|
375
|
-
overscroll-behavior-y: none;
|
|
376
|
-
overflow: hidden;
|
|
377
|
-
position: fixed;
|
|
378
|
-
width: 100%;
|
|
379
|
-
margin: 0;
|
|
380
|
-
max-height: 100%;
|
|
381
|
-
-webkit-overflow-scrolling: touch;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
371
|
|
|
385
372
|
</style>
|