@thinkpixellab-public/px-vue 3.0.50 → 3.0.53

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.
@@ -5,7 +5,10 @@
5
5
 
6
6
  -->
7
7
  <template>
8
- <div :class="bem({ scrolls: scrolls, animated: animated })">
8
+ <div
9
+ :class="bem({ scrolls: scrolls, animated: animated, loading: loading })"
10
+ :style="{ opacity: loading ? 0 : null }"
11
+ >
9
12
  <div :class="bem('tabs-align', { justify: justify })">
10
13
  <div ref="tabs" :class="bem('tabs')">
11
14
  <button
@@ -16,7 +19,7 @@
16
19
  @click="itemClick(item)"
17
20
  >
18
21
  <span :ref="getTabContentRefName(item)">
19
- <slot :item="item">
22
+ <slot :item="item" :selected="isItemSelected(item)">
20
23
  {{ getItemLabel(item) }}
21
24
  </slot>
22
25
  </span>
@@ -28,7 +31,9 @@
28
31
  left: cssPx(selectorOffset),
29
32
  width: cssPx(selectorWidth),
30
33
  }"
31
- ></div>
34
+ >
35
+ <slot name="selector"></slot>
36
+ </div>
32
37
  </div>
33
38
  </div>
34
39
  </div>
@@ -62,6 +67,7 @@ export default {
62
67
  selectorOffset: 0,
63
68
  selectorWidth: 0,
64
69
  animated: false,
70
+ loading: true,
65
71
  };
66
72
  },
67
73
  // computed: {},
@@ -80,6 +86,14 @@ export default {
80
86
  },
81
87
  },
82
88
  },
89
+ mounted() {
90
+ setTimeout(() => {
91
+ this.updateSelector();
92
+ setTimeout(() => {
93
+ this.loading = false;
94
+ }, 50);
95
+ }, 50);
96
+ },
83
97
 
84
98
  methods: {
85
99
  resize() {
@@ -178,10 +192,10 @@ export default {
178
192
  &__tab-base {
179
193
  @include control-reset();
180
194
  background-color: transparent;
195
+ flex: none;
181
196
  }
182
197
 
183
198
  &__tab {
184
- flex: none;
185
199
  padding: var(--px-pivot-tab-padding);
186
200
  cursor: pointer;
187
201
  &:disabled {
@@ -194,6 +208,9 @@ export default {
194
208
  position: absolute;
195
209
  bottom: 0;
196
210
  left: 0;
211
+ }
212
+
213
+ &__selector {
197
214
  height: 2px;
198
215
  background-color: currentColor;
199
216
  }
@@ -203,5 +220,11 @@ export default {
203
220
  @include transition(width left);
204
221
  }
205
222
  }
223
+
224
+ &--loading {
225
+ * {
226
+ transition: none !important;
227
+ }
228
+ }
206
229
  }
207
230
  </style>
@@ -48,6 +48,8 @@ export default {
48
48
  duration: { type: Number, default: 1 },
49
49
  ease: { type: String, default: 'power3.out' },
50
50
  slideAmount: { default: '40vw' },
51
+
52
+ disableAnimations: { type: Boolean, default: false },
51
53
  },
52
54
  computed: {
53
55
  tweenShared() {
@@ -57,6 +59,11 @@ export default {
57
59
  };
58
60
  },
59
61
  },
62
+ mounted() {
63
+ if (this.disableAnimations) {
64
+ gsap.globalTimeline.timeScale(Number.MAX_VALUE);
65
+ }
66
+ },
60
67
  methods: {
61
68
  directionAmount(direction, addEquals = false) {
62
69
  let dir;
@@ -10,6 +10,7 @@
10
10
  :class="bem('slide-wrapper', { selected: isItemSelected(item) })"
11
11
  >
12
12
  <px-slide-transition
13
+ :disable-animations="disableAnimations"
13
14
  :direction="direction"
14
15
  @before-leave="transitionStart"
15
16
  @after-leave="transitionEnd"
@@ -73,6 +74,9 @@ export default {
73
74
 
74
75
  // override default
75
76
  autoSelectFirst: { type: Boolean, default: true },
77
+
78
+ // disable animations
79
+ disableAnimations: { type: Boolean, default: false },
76
80
  },
77
81
 
78
82
  data() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thinkpixellab-public/px-vue",
3
- "version": "3.0.50",
3
+ "version": "3.0.53",
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/utils.js CHANGED
@@ -13,6 +13,22 @@ export default {
13
13
  return Math.min(Math.max(value, min), max);
14
14
  },
15
15
 
16
+ /**
17
+ * Safely gets an item from an array, otherwise returns a fallback value.
18
+ * @param {*} arr The array.
19
+ * @param {*} index The starting index.
20
+ * @param {*} offset The offset from the starting index.
21
+ * @param {*} wrap When true out-of-bounds indices will wrap, otherwise they will be clamped.
22
+ * @param {*} fallback The value to be returned if the item can't be retrieved.
23
+ * @return {*} An item from the array;
24
+ */
25
+ arraySafeGet: function (arr, index, offset = 0, wrap = false, fallback = null) {
26
+ const safeIndex = this.arraySafeIndex(arr, index, offset, wrap);
27
+ if (index > -1) {
28
+ return arr[safeIndex];
29
+ }
30
+ return fallback;
31
+ },
16
32
  /**
17
33
  * Method for calculating a safe index into an array for a given starting point and offset.
18
34
  * Offset can be very large or negative.
@@ -185,6 +201,28 @@ export default {
185
201
  };
186
202
  },
187
203
 
204
+ /**
205
+ * Returns the outer dimensions of an element include padding, margin, border, etc.
206
+ *
207
+ * @param {element} element The element to be measured
208
+ */
209
+ getOuterSize(element) {
210
+ if (!element || typeof window == 'undefined') {
211
+ return { width: 0, height: 0 };
212
+ }
213
+ const styles = window.getComputedStyle(element);
214
+ return {
215
+ width:
216
+ element.offsetWidth +
217
+ parseFloat(styles['marginLeft']) +
218
+ parseFloat(styles['marginRight']),
219
+ height:
220
+ element.offsetHeight +
221
+ parseFloat(styles['marginTop']) +
222
+ parseFloat(styles['marginBottom']),
223
+ };
224
+ },
225
+
188
226
  /**
189
227
  * Returns a simple seeded random number function. This turns out to be really useful when trying
190
228
  * to keep state in sync between nuxt and client. If seed is null, returns an instance that has