@thinkpixellab-public/px-vue 3.0.62 → 3.0.64
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/components/PxContain.vue +2 -2
- package/components/PxGsapScrubber.vue +1 -1
- package/components/PxSlides.vue +38 -16
- package/package.json +1 -1
- package/utils/drag.js +2 -1
- package/utils/lethargy.js +11 -2
package/components/PxContain.vue
CHANGED
|
@@ -182,8 +182,8 @@ export default {
|
|
|
182
182
|
let inner = this.aspectRect || outer;
|
|
183
183
|
|
|
184
184
|
outer = {
|
|
185
|
-
width: outer.width - (b.w + p.w),
|
|
186
|
-
height: outer.height - (b.h + p.h),
|
|
185
|
+
width: Math.max(0, outer.width - (b.w + p.w)),
|
|
186
|
+
height: Math.max(0, outer.height - (b.h + p.h)),
|
|
187
187
|
};
|
|
188
188
|
|
|
189
189
|
// max width/height
|
package/components/PxSlides.vue
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Describe this component...
|
|
3
3
|
-->
|
|
4
4
|
<template>
|
|
5
|
-
<div :class="bem()">
|
|
5
|
+
<div :class="bem(variantsMap)">
|
|
6
6
|
<div
|
|
7
7
|
v-for="(item, index) in items"
|
|
8
8
|
:key="getItemKey(item)"
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
import PxBaseItemsSelect from './PxBaseItemsSelect.vue';
|
|
44
44
|
import PxSlideTransition from './PxSlideTransition.vue';
|
|
45
45
|
import PxIcon from './PxIcon.vue';
|
|
46
|
+
import PxBaseVariants from './PxBaseVariants.vue';
|
|
46
47
|
|
|
47
48
|
import gsap from 'gsap';
|
|
48
49
|
import Drag from '../utils/drag.js';
|
|
@@ -50,7 +51,7 @@ import Lethargy from '../utils/lethargy.js';
|
|
|
50
51
|
|
|
51
52
|
export default {
|
|
52
53
|
name: 'px-slides',
|
|
53
|
-
mixins: [PxBaseItemsSelect],
|
|
54
|
+
mixins: [PxBaseItemsSelect, PxBaseVariants],
|
|
54
55
|
components: { PxSlideTransition, PxIcon },
|
|
55
56
|
|
|
56
57
|
props: {
|
|
@@ -72,6 +73,8 @@ export default {
|
|
|
72
73
|
// exclude from drag
|
|
73
74
|
dragExcludeSelector: { type: String, default: 'input, button, [data-no-drag]' },
|
|
74
75
|
|
|
76
|
+
scrollExcludeSelector: { type: String, default: '[data-no-slidescroll]' },
|
|
77
|
+
|
|
75
78
|
// override default
|
|
76
79
|
autoSelectFirst: { type: Boolean, default: true },
|
|
77
80
|
|
|
@@ -157,15 +160,6 @@ export default {
|
|
|
157
160
|
},
|
|
158
161
|
},
|
|
159
162
|
mounted() {
|
|
160
|
-
this.drag = new Drag(this.$el, {
|
|
161
|
-
lock: 'x',
|
|
162
|
-
onStart: this.onDragStart,
|
|
163
|
-
onDrag: this.onDrag,
|
|
164
|
-
onEnd: this.onDragEnd,
|
|
165
|
-
excludeSelector: this.dragExcludeSelector,
|
|
166
|
-
disabled: !this.dragEnabled,
|
|
167
|
-
});
|
|
168
|
-
|
|
169
163
|
if (this.scrollEnabled) {
|
|
170
164
|
let overrides = this.lethargyOverrides;
|
|
171
165
|
|
|
@@ -183,6 +177,15 @@ export default {
|
|
|
183
177
|
|
|
184
178
|
this.$el.addEventListener('wheel', this.onWheel);
|
|
185
179
|
}
|
|
180
|
+
|
|
181
|
+
this.drag = new Drag(this.$el, {
|
|
182
|
+
lock: 'x',
|
|
183
|
+
onStart: this.onDragStart,
|
|
184
|
+
onDrag: this.onDrag,
|
|
185
|
+
onEnd: this.onDragEnd,
|
|
186
|
+
excludeSelector: this.dragExcludeSelector,
|
|
187
|
+
disabled: !this.dragEnabled,
|
|
188
|
+
});
|
|
186
189
|
},
|
|
187
190
|
beforeDestroy() {
|
|
188
191
|
if (this.drag) {
|
|
@@ -242,6 +245,10 @@ export default {
|
|
|
242
245
|
},
|
|
243
246
|
|
|
244
247
|
onWheel(e) {
|
|
248
|
+
if (!this.scrollEnabled) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
|
|
245
252
|
if (this.scrollPreviewEnabled) {
|
|
246
253
|
const delta = (e.deltaY + e.deltaX) / 2;
|
|
247
254
|
if (Math.abs(delta) > 5) {
|
|
@@ -249,11 +256,19 @@ export default {
|
|
|
249
256
|
}
|
|
250
257
|
|
|
251
258
|
clearTimeout(this.scrollPreviewTimeout);
|
|
259
|
+
|
|
252
260
|
this.scrollPreviewTimeout = setTimeout(() => {
|
|
253
261
|
this.scrollPreview = 0;
|
|
254
262
|
}, 200);
|
|
255
263
|
}
|
|
256
264
|
|
|
265
|
+
if (this.scrollExcludeSelector) {
|
|
266
|
+
const excludeElements = this.$el.querySelectorAll(this.scrollExcludeSelector);
|
|
267
|
+
for (let i = 0; i < excludeElements.length; i++) {
|
|
268
|
+
if (excludeElements[i].contains(e.target)) return;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
257
272
|
const check = this.lethargy.check(e);
|
|
258
273
|
|
|
259
274
|
if (check !== this.lethargyPrevCheck) {
|
|
@@ -266,13 +281,13 @@ export default {
|
|
|
266
281
|
} else {
|
|
267
282
|
this.next(false);
|
|
268
283
|
}
|
|
284
|
+
|
|
285
|
+
e.stopPropagation();
|
|
286
|
+
e.preventDefault();
|
|
269
287
|
}
|
|
270
288
|
}
|
|
271
289
|
|
|
272
290
|
this.lethargyPrevCheck = check;
|
|
273
|
-
|
|
274
|
-
e.stopPropagation();
|
|
275
|
-
e.preventDefault();
|
|
276
291
|
},
|
|
277
292
|
|
|
278
293
|
next(loopOverride = null) {
|
|
@@ -316,8 +331,8 @@ export default {
|
|
|
316
331
|
|
|
317
332
|
.px-slides {
|
|
318
333
|
display: grid;
|
|
319
|
-
grid-template-columns:
|
|
320
|
-
grid-template-rows:
|
|
334
|
+
grid-template-columns: 1fr;
|
|
335
|
+
grid-template-rows: 1fr;
|
|
321
336
|
grid-template-areas: 'content';
|
|
322
337
|
-webkit-transform-style: preserve-3d;
|
|
323
338
|
|
|
@@ -370,5 +385,12 @@ export default {
|
|
|
370
385
|
opacity: 1;
|
|
371
386
|
}
|
|
372
387
|
}
|
|
388
|
+
|
|
389
|
+
// variant (replaces 1fr row/columns with 100%)
|
|
390
|
+
|
|
391
|
+
&--anchored {
|
|
392
|
+
grid-template-columns: 100%;
|
|
393
|
+
grid-template-rows: 100%;
|
|
394
|
+
}
|
|
373
395
|
}
|
|
374
396
|
</style>
|
package/package.json
CHANGED
package/utils/drag.js
CHANGED
|
@@ -60,6 +60,7 @@ function Drag(element, options) {
|
|
|
60
60
|
|
|
61
61
|
this.onStart = nativeEvent => {
|
|
62
62
|
if (this.disabled) {
|
|
63
|
+
debugger;
|
|
63
64
|
return;
|
|
64
65
|
}
|
|
65
66
|
|
|
@@ -338,7 +339,7 @@ function Drag(element, options) {
|
|
|
338
339
|
|
|
339
340
|
this.enable = () => {
|
|
340
341
|
this.reset();
|
|
341
|
-
this.
|
|
342
|
+
this.disabled = false;
|
|
342
343
|
};
|
|
343
344
|
|
|
344
345
|
this.destroy = () => {
|
package/utils/lethargy.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Adapted from here: https://github.com/d4nyll/lethargy
|
|
2
2
|
// MIT License
|
|
3
3
|
|
|
4
|
+
/*
|
|
5
|
+
Look for "CHANGE" comments to see dif from github
|
|
6
|
+
*/
|
|
7
|
+
|
|
4
8
|
function Lethargy(stability, sensitivity, tolerance, delay) {
|
|
5
9
|
this.stability = stability != null ? Math.abs(stability) : 8;
|
|
6
10
|
this.sensitivity = sensitivity != null ? 1 + Math.abs(sensitivity) : 100;
|
|
@@ -65,14 +69,19 @@ Lethargy.prototype.check = function (e) {
|
|
|
65
69
|
this.lastDownDeltas.shift();
|
|
66
70
|
return this.isInertia(-1);
|
|
67
71
|
}
|
|
68
|
-
|
|
72
|
+
|
|
73
|
+
// CHANGE: this code is never reached so we comment it out
|
|
74
|
+
// return false;
|
|
69
75
|
};
|
|
70
76
|
|
|
71
77
|
Lethargy.prototype.isInertia = function (direction) {
|
|
72
78
|
var lastDeltas, lastDeltasNew, lastDeltasOld, newAverage, newSum, oldAverage, oldSum;
|
|
73
79
|
lastDeltas = direction === -1 ? this.lastDownDeltas : this.lastUpDeltas;
|
|
74
80
|
if (lastDeltas[0] === null) {
|
|
75
|
-
return direction
|
|
81
|
+
// CHANGE: previously this would return direction when the deltas queue was initialzied with
|
|
82
|
+
// null but that caused the initial wheel event to always fire unti we had a full cache, so
|
|
83
|
+
// now we return false until the cache is full.
|
|
84
|
+
return false;
|
|
76
85
|
}
|
|
77
86
|
if (
|
|
78
87
|
this.deltasTimestamp[this.stability * 2 - 2] + this.delay > Date.now() &&
|