@thinkpixellab-public/px-vue 3.0.61 → 3.0.63

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.
@@ -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
@@ -59,7 +59,7 @@ export default {
59
59
  },
60
60
  // watch: {},
61
61
  // mounted() {},
62
- beforeUnmount() {
62
+ beforeDestroy() {
63
63
  if (this.timeline) {
64
64
  this.timeline.eventCallback('onUpdate', null);
65
65
  }
@@ -22,7 +22,6 @@
22
22
  "
23
23
  v-on="$listeners"
24
24
  @click="tryToggleChecked"
25
- :aria-label="label"
26
25
  >
27
26
  <inline-svg
28
27
  :transformSource="transform"
@@ -45,8 +44,6 @@ export default {
45
44
  props: {
46
45
  // set to true for icon to toggle on and off
47
46
  toggles: { type: Boolean, default: false },
48
- // aria label value for the button
49
- label: { type: String, default: null },
50
47
  },
51
48
  methods: {
52
49
  tryToggleChecked() {
@@ -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) {
@@ -249,11 +252,19 @@ export default {
249
252
  }
250
253
 
251
254
  clearTimeout(this.scrollPreviewTimeout);
255
+
252
256
  this.scrollPreviewTimeout = setTimeout(() => {
253
257
  this.scrollPreview = 0;
254
258
  }, 200);
255
259
  }
256
260
 
261
+ if (this.scrollExcludeSelector) {
262
+ const excludeElements = this.$el.querySelectorAll(this.scrollExcludeSelector);
263
+ for (let i = 0; i < excludeElements.length; i++) {
264
+ if (excludeElements[i].contains(e.target)) return;
265
+ }
266
+ }
267
+
257
268
  const check = this.lethargy.check(e);
258
269
 
259
270
  if (check !== this.lethargyPrevCheck) {
@@ -266,13 +277,13 @@ export default {
266
277
  } else {
267
278
  this.next(false);
268
279
  }
280
+
281
+ e.stopPropagation();
282
+ e.preventDefault();
269
283
  }
270
284
  }
271
285
 
272
286
  this.lethargyPrevCheck = check;
273
-
274
- e.stopPropagation();
275
- e.preventDefault();
276
287
  },
277
288
 
278
289
  next(loopOverride = null) {
@@ -316,8 +327,8 @@ export default {
316
327
 
317
328
  .px-slides {
318
329
  display: grid;
319
- grid-template-columns: 100%;
320
- grid-template-rows: 100%;
330
+ grid-template-columns: 1fr;
331
+ grid-template-rows: 1fr;
321
332
  grid-template-areas: 'content';
322
333
  -webkit-transform-style: preserve-3d;
323
334
 
@@ -370,5 +381,12 @@ export default {
370
381
  opacity: 1;
371
382
  }
372
383
  }
384
+
385
+ // variant (replaces 1fr row/columns with 100%)
386
+
387
+ &--anchored {
388
+ grid-template-columns: 100%;
389
+ grid-template-rows: 100%;
390
+ }
373
391
  }
374
392
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.61",
3
+ "version": "3.0.63",
4
4
  "description": "General purpose Vue components and helpers that can be used across projects.",
5
5
  "author": "Pixel Lab",
6
6
  "license": "MIT",
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.disable = false;
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
- return false;
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() &&