@mixd-id/web-scaffold 0.1.230406187 → 0.1.230406189

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mixd-id/web-scaffold",
3
3
  "private": false,
4
- "version": "0.1.230406187",
4
+ "version": "0.1.230406189",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div :class="$style.comp" @mousedown.prevent="mouseDown" @touchstart.passive="mouseDown">
2
+ <div :class="$style.comp" @mousedown="mouseDown" @touchstart.passive="mouseDown">
3
3
 
4
4
  <div ref="inner" :class="computedContainerClass">
5
5
  <div v-for="item in items" :class="computedItemClass">
@@ -97,7 +97,6 @@ export default{
97
97
  data(){
98
98
  return {
99
99
  index: 0,
100
- scrolling: 0,
101
100
  timeoutId: null
102
101
  }
103
102
  },
@@ -116,7 +115,7 @@ export default{
116
115
 
117
116
  items(){
118
117
  this.index = 0
119
- }
118
+ },
120
119
 
121
120
  },
122
121
 
@@ -195,41 +194,45 @@ export default{
195
194
  },
196
195
 
197
196
  mouseMove(e){
198
-
199
- this.scrolling = true
200
-
201
197
  const sx = typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX
198
+ const sy = typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY
202
199
  const dx = sx - this._props['sx']
200
+ const dy = sy - this._props['sy']
203
201
  const ix = parseInt(this._props['ix'] + dx)
204
202
 
205
- //console.warn('mousemove', dx, ix)
203
+ if(!this._props['direction']){
204
+ if(Math.abs(dy) > 10){
205
+ this._props['direction'] = 'vertical'
206
+ }
207
+ else if(Math.abs(dx) > 15){
208
+ this._props['direction'] = 'horizontal'
209
+ document.body.classList.add(this.$style.noScroll)
210
+ }
211
+ }
212
+ else if(this._props['direction'] === 'horizontal'){
213
+ this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
214
+ }
206
215
 
207
- this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
208
216
  },
209
217
 
210
218
  mouseUp(e){
211
-
212
- window.setTimeout(() => {
213
- this.scrolling = false
214
- }, 50)
215
-
216
- const tn = e.timeStamp - this._props['t0']
217
- const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
218
- const dx = sx - this._props['sx']
219
-
220
- //console.warn('mouseup', tn, dx, dx)
221
-
222
- if (Math.abs(dx) > 10) {
223
- if (tn < 1200){
224
- dx < 0 ? this.next(true) : this.prev(true)
219
+ if(this._props['direction'] === 'horizontal'){
220
+ const tn = e.timeStamp - this._props['t0']
221
+ const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
222
+ const dx = sx - this._props['sx']
223
+
224
+ if (Math.abs(dx) > 10) {
225
+ if (tn < 1200){
226
+ dx < 0 ? this.next(true) : this.prev(true)
227
+ }
228
+ else{
229
+ this.setPosition()
230
+ }
225
231
  }
226
232
  else{
227
233
  this.setPosition()
228
234
  }
229
235
  }
230
- else{
231
- this.setPosition()
232
- }
233
236
 
234
237
  window.removeEventListener('mousemove', this.mouseMove)
235
238
  window.removeEventListener('mouseup', this.mouseUp)
@@ -237,12 +240,13 @@ export default{
237
240
  window.removeEventListener('touchmove', this.mouseMove)
238
241
  window.removeEventListener('touchend', this.mouseUp)
239
242
 
243
+ document.body.classList.remove(this.$style.noScroll)
244
+
240
245
  if(this.autoPlay > 0)
241
246
  this.play()
242
247
  },
243
248
 
244
249
  mouseDown(e){
245
-
246
250
  if(!this.items || this.items.length <= 1)
247
251
  return
248
252
 
@@ -253,8 +257,10 @@ export default{
253
257
 
254
258
  this._props = {
255
259
  sx:typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX,
260
+ sy:typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY,
256
261
  ix:ix,
257
- t0:e.timeStamp
262
+ t0:e.timeStamp,
263
+ direction: null
258
264
  }
259
265
 
260
266
  window.addEventListener('mousemove', this.mouseMove)
@@ -294,8 +300,16 @@ export default{
294
300
  white-space: nowrap;
295
301
  overflow: hidden;
296
302
  position: relative;
297
- touch-action: none;
298
303
  background-image: v-bind(bgImages[0]);
304
+ /*touch-action: none;*/
305
+ }
306
+
307
+ .comp.noTouchAction{
308
+ /*touch-action: none;*/
309
+ }
310
+
311
+ .comp img{
312
+ pointer-events: none;
299
313
  }
300
314
 
301
315
  .carouselNext{
@@ -309,14 +323,12 @@ export default{
309
323
  .inner{
310
324
  white-space: nowrap;
311
325
  will-change: transform;
312
- touch-action: none;
313
326
  @apply flex flex-row items-stretch;
314
327
  }
315
328
  .inner>*{
316
329
  display: inline-block;
317
330
  width: 100%;
318
331
  min-width: 100%;
319
- touch-action: none;
320
332
  vertical-align: top;
321
333
  }
322
334
 
@@ -336,6 +348,10 @@ export default{
336
348
  @apply bg-primary-500;
337
349
  }
338
350
 
351
+ .noScroll{
352
+ overflow: hidden
353
+ }
354
+
339
355
  @media screen(md){
340
356
  .comp{
341
357
  background-image: v-bind(bgImages[1]);