@thinkpixellab-public/px-vue 3.0.49 → 3.0.51
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/PxFloat.vue +0 -1
- package/components/PxPivot.vue +27 -4
- package/package.json +1 -1
- package/utils/utils.js +38 -0
package/components/PxFloat.vue
CHANGED
|
@@ -499,7 +499,6 @@ export default {
|
|
|
499
499
|
middlewareData?.flip && Object.keys(middlewareData.flip).length
|
|
500
500
|
);
|
|
501
501
|
|
|
502
|
-
console.log(`middlewareData: 👉 ${JSON.stringify(middlewareData, null, 4)}`);
|
|
503
502
|
if (this.useTranslate) {
|
|
504
503
|
this.positionCss = {
|
|
505
504
|
transform: `translate(${this.cssPx(x)},${this.cssPx(y)})`,
|
package/components/PxPivot.vue
CHANGED
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
|
|
6
6
|
-->
|
|
7
7
|
<template>
|
|
8
|
-
<div
|
|
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
|
-
|
|
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>
|
package/package.json
CHANGED
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
|