@thinkpixellab-public/px-vue 3.0.75 → 3.0.76
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/PxArrowScroller.vue +6 -1
- package/components/PxBaseVariantsOverride.vue +1 -1
- package/package.json +1 -1
- package/utils/cssStr.js +29 -16
- package/utils/utils.js +35 -0
|
@@ -30,7 +30,12 @@ ar
|
|
|
30
30
|
</slot>
|
|
31
31
|
</button>
|
|
32
32
|
|
|
33
|
-
<div
|
|
33
|
+
<div
|
|
34
|
+
:class="bem('scroller', { disabled })"
|
|
35
|
+
ref="scroller"
|
|
36
|
+
@scroll="updateScrollArrows"
|
|
37
|
+
data-no-drag
|
|
38
|
+
>
|
|
34
39
|
<slot />
|
|
35
40
|
</div>
|
|
36
41
|
|
package/package.json
CHANGED
package/utils/cssStr.js
CHANGED
|
@@ -58,6 +58,18 @@ function cssVar(val) {
|
|
|
58
58
|
return null;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/*
|
|
62
|
+
Extract the number from a css value
|
|
63
|
+
cssNum('10px') => 10
|
|
64
|
+
cssNum(10) => 10
|
|
65
|
+
cssNum('auto') => 0
|
|
66
|
+
cssNum('auto', null) => null
|
|
67
|
+
*/
|
|
68
|
+
function cssNum(val, nanValue = 0) {
|
|
69
|
+
const num = parseFloat(val);
|
|
70
|
+
return isNaN(num) ? nanValue : num;
|
|
71
|
+
}
|
|
72
|
+
|
|
61
73
|
/*
|
|
62
74
|
Extract the unit from a css value
|
|
63
75
|
cssUnit('10px') => 'px'
|
|
@@ -81,16 +93,16 @@ function cssUnit(val) {
|
|
|
81
93
|
return '';
|
|
82
94
|
}
|
|
83
95
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const num =
|
|
93
|
-
return
|
|
96
|
+
/**
|
|
97
|
+
* Scales a css value while leaving the unit intact.
|
|
98
|
+
* @param {string} val The css value to scale
|
|
99
|
+
* @example
|
|
100
|
+
* cssUnitScale('10px', 2) => '20px'
|
|
101
|
+
*/
|
|
102
|
+
function cssUnitScale(val, scaler) {
|
|
103
|
+
const unit = cssUnit(val);
|
|
104
|
+
const num = cssNum(val);
|
|
105
|
+
return `${num * scaler}${unit}`;
|
|
94
106
|
}
|
|
95
107
|
|
|
96
108
|
/*
|
|
@@ -183,16 +195,16 @@ function cssUnitFallback(val, fallback, allowNumberless = false) {
|
|
|
183
195
|
return `${num}${unit}`;
|
|
184
196
|
}
|
|
185
197
|
|
|
186
|
-
|
|
187
|
-
Ems version of cssUnitFallback
|
|
188
|
-
*/
|
|
198
|
+
/**
|
|
199
|
+
* Ems version of cssUnitFallback
|
|
200
|
+
*/
|
|
189
201
|
function cssEmFallback(val, allowNumberless = false) {
|
|
190
202
|
return cssUnitFallback(val, 'em', allowNumberless);
|
|
191
203
|
}
|
|
192
204
|
|
|
193
|
-
|
|
194
|
-
Px version of cssUnitFallback
|
|
195
|
-
*/
|
|
205
|
+
/**
|
|
206
|
+
* Px version of cssUnitFallback
|
|
207
|
+
*/
|
|
196
208
|
function cssPxFallback(val, allowNumberless = false) {
|
|
197
209
|
return cssUnitFallback(val, 'px', allowNumberless);
|
|
198
210
|
}
|
|
@@ -206,6 +218,7 @@ export {
|
|
|
206
218
|
cssAspect,
|
|
207
219
|
cssNum,
|
|
208
220
|
cssUnit,
|
|
221
|
+
cssUnitScale,
|
|
209
222
|
cssUnitFallback,
|
|
210
223
|
cssEmFallback,
|
|
211
224
|
cssPxFallback,
|
package/utils/utils.js
CHANGED
|
@@ -13,6 +13,20 @@ export default {
|
|
|
13
13
|
return Math.min(Math.max(value, min), max);
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Ensure that a value is an array. If the value isn't an array, wrap it. If the value is null
|
|
18
|
+
* or undefined, an empty array is returned (0 and false will be wrapped).
|
|
19
|
+
*
|
|
20
|
+
* @param {*} value Any array or non-array value.
|
|
21
|
+
* @return {*} An array.
|
|
22
|
+
*/
|
|
23
|
+
ensureArray: function (value) {
|
|
24
|
+
if (value === null || value === undefined) {
|
|
25
|
+
return [];
|
|
26
|
+
}
|
|
27
|
+
return Array.isArray(value) ? value : [value];
|
|
28
|
+
},
|
|
29
|
+
|
|
16
30
|
/**
|
|
17
31
|
* Safely gets an item from an array, otherwise returns a fallback value.
|
|
18
32
|
* @param {*} arr The array.
|
|
@@ -29,6 +43,7 @@ export default {
|
|
|
29
43
|
}
|
|
30
44
|
return fallback;
|
|
31
45
|
},
|
|
46
|
+
|
|
32
47
|
/**
|
|
33
48
|
* Method for calculating a safe index into an array for a given starting point and offset.
|
|
34
49
|
* Offset can be very large or negative.
|
|
@@ -148,6 +163,26 @@ export default {
|
|
|
148
163
|
return arrA.filter(value => arrB.includes(value));
|
|
149
164
|
},
|
|
150
165
|
|
|
166
|
+
/**
|
|
167
|
+
* Returns true if the two arrays have any common items.
|
|
168
|
+
* @param {*} arr1 The first array
|
|
169
|
+
* @param {*} arr2 The second array
|
|
170
|
+
* @return True if the arrays have any common items
|
|
171
|
+
*/
|
|
172
|
+
arrayHasCommonItem(arr1, arr2) {
|
|
173
|
+
if (!arr1 || !arr2) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
178
|
+
if (arr2.indexOf(arr1[i]) > -1) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
return false;
|
|
184
|
+
},
|
|
185
|
+
|
|
151
186
|
/**
|
|
152
187
|
* Returns an object representing the current query string parameters.
|
|
153
188
|
*/
|