@mixd-id/web-scaffold 0.1.230406188 → 0.1.230406191

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.230406188",
4
+ "version": "0.1.230406191",
5
5
  "scripts": {
6
6
  "dev": "vite serve",
7
7
  "build": "vite build",
@@ -97,7 +97,8 @@ export default{
97
97
  data(){
98
98
  return {
99
99
  index: 0,
100
- timeoutId: null
100
+ timeoutId: null,
101
+ scrollPosition: null,
101
102
  }
102
103
  },
103
104
 
@@ -115,7 +116,7 @@ export default{
115
116
 
116
117
  items(){
117
118
  this.index = 0
118
- }
119
+ },
119
120
 
120
121
  },
121
122
 
@@ -195,27 +196,45 @@ export default{
195
196
 
196
197
  mouseMove(e){
197
198
  const sx = typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX
199
+ const sy = typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY
198
200
  const dx = sx - this._props['sx']
201
+ const dy = sy - this._props['sy']
199
202
  const ix = parseInt(this._props['ix'] + dx)
200
203
 
201
- this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
204
+ if(!this._props['direction']){
205
+ if(Math.abs(dy) > 10){
206
+ this._props['direction'] = 'vertical'
207
+ }
208
+ else if(Math.abs(dx) > 15){
209
+ this._props['direction'] = 'horizontal'
210
+ this.disableBodyScroll()
211
+ }
212
+ }
213
+ else if(this._props['direction'] === 'horizontal'){
214
+ this.$el.firstElementChild.style.transform = `translate3d(${ix}px, 0, 0)`
215
+ }
216
+
202
217
  },
203
218
 
204
219
  mouseUp(e){
205
- const tn = e.timeStamp - this._props['t0']
206
- const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
207
- const dx = sx - this._props['sx']
208
-
209
- if (Math.abs(dx) > 10) {
210
- if (tn < 1200){
211
- dx < 0 ? this.next(true) : this.prev(true)
220
+ if(this._props['direction'] === 'horizontal'){
221
+ const tn = e.timeStamp - this._props['t0']
222
+ const sx = typeof e.changedTouches !== 'undefined' ? e.changedTouches[0].clientX : e.clientX
223
+ const dx = sx - this._props['sx']
224
+
225
+ if (Math.abs(dx) > 10) {
226
+ if (tn < 1200){
227
+ dx < 0 ? this.next(true) : this.prev(true)
228
+ }
229
+ else{
230
+ this.setPosition()
231
+ }
212
232
  }
213
233
  else{
214
234
  this.setPosition()
215
235
  }
216
- }
217
- else{
218
- this.setPosition()
236
+
237
+ this.enableBodyScroll()
219
238
  }
220
239
 
221
240
  window.removeEventListener('mousemove', this.mouseMove)
@@ -228,6 +247,22 @@ export default{
228
247
  this.play()
229
248
  },
230
249
 
250
+ disableBodyScroll(){
251
+ this.scrollPosition = window.pageYOffset || document.documentElement.offsetTop
252
+ document.body.style.overflow = 'hidden';
253
+ document.body.style.position = 'fixed';
254
+ document.body.style.top = `-${this.scrollPosition}px`;
255
+ document.body.style.width = '100%';
256
+ },
257
+
258
+ enableBodyScroll(){
259
+ document.body.style.removeProperty('overflow');
260
+ document.body.style.removeProperty('position');
261
+ document.body.style.removeProperty('top');
262
+ document.body.style.removeProperty('width');
263
+ window.scrollTo(0, this.scrollPosition);
264
+ },
265
+
231
266
  mouseDown(e){
232
267
  if(!this.items || this.items.length <= 1)
233
268
  return
@@ -239,8 +274,10 @@ export default{
239
274
 
240
275
  this._props = {
241
276
  sx:typeof e.touches !== 'undefined' ? e.touches[0].clientX : e.clientX,
277
+ sy:typeof e.touches !== 'undefined' ? e.touches[0].clientY : e.clientY,
242
278
  ix:ix,
243
- t0:e.timeStamp
279
+ t0:e.timeStamp,
280
+ direction: null
244
281
  }
245
282
 
246
283
  window.addEventListener('mousemove', this.mouseMove)
@@ -281,10 +318,11 @@ export default{
281
318
  overflow: hidden;
282
319
  position: relative;
283
320
  background-image: v-bind(bgImages[0]);
321
+ /*touch-action: none;*/
284
322
  }
285
323
 
286
324
  .comp.noTouchAction{
287
- touch-action: none;
325
+ /*touch-action: none;*/
288
326
  }
289
327
 
290
328
  .comp img{
@@ -302,14 +340,12 @@ export default{
302
340
  .inner{
303
341
  white-space: nowrap;
304
342
  will-change: transform;
305
- //touch-action: none;
306
343
  @apply flex flex-row items-stretch;
307
344
  }
308
345
  .inner>*{
309
346
  display: inline-block;
310
347
  width: 100%;
311
348
  min-width: 100%;
312
- //touch-action: none;
313
349
  vertical-align: top;
314
350
  }
315
351
 
@@ -329,6 +365,9 @@ export default{
329
365
  @apply bg-primary-500;
330
366
  }
331
367
 
368
+ .bodyNoScroll{
369
+ }
370
+
332
371
  @media screen(md){
333
372
  .comp{
334
373
  background-image: v-bind(bgImages[1]);