@weni/unnnic-system 1.24.21 → 1.24.22
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/CHANGELOG.md +6 -0
- package/dist/unnnic.common.js +96 -57
- package/dist/unnnic.common.js.map +1 -1
- package/dist/unnnic.css +1 -1
- package/dist/unnnic.umd.js +96 -57
- package/dist/unnnic.umd.js.map +1 -1
- package/dist/unnnic.umd.min.js +8 -8
- package/dist/unnnic.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Slider/Slider.vue +43 -9
package/package.json
CHANGED
|
@@ -123,10 +123,8 @@ export default {
|
|
|
123
123
|
window.removeEventListener('resize', this.handleResize);
|
|
124
124
|
},
|
|
125
125
|
mounted() {
|
|
126
|
-
|
|
127
|
-
this.
|
|
128
|
-
this.labelWidth = this.$refs.tooltip.$refs.label.clientWidth || fallbackLabelWidth;
|
|
129
|
-
this.tooltipOffset = this.getNewTooltipPosition();
|
|
126
|
+
this.checkInputWidth();
|
|
127
|
+
this.checkTooltipLabelWidth();
|
|
130
128
|
},
|
|
131
129
|
watch: {
|
|
132
130
|
sliderVal: {
|
|
@@ -146,8 +144,13 @@ export default {
|
|
|
146
144
|
},
|
|
147
145
|
methods: {
|
|
148
146
|
configureTooltip() {
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
if (this.$refs.input) {
|
|
148
|
+
this.sliderWidth = this.$refs.input.clientWidth;
|
|
149
|
+
}
|
|
150
|
+
const tooltipLabel = this.$refs.tooltip?.$refs.label;
|
|
151
|
+
if (tooltipLabel) {
|
|
152
|
+
this.labelWidth = tooltipLabel.clientWidth || 32;
|
|
153
|
+
}
|
|
151
154
|
this.tooltipOffset = this.getNewTooltipPosition();
|
|
152
155
|
},
|
|
153
156
|
handleResize() {
|
|
@@ -162,9 +165,40 @@ export default {
|
|
|
162
165
|
|
|
163
166
|
this.handleValueChange();
|
|
164
167
|
},
|
|
168
|
+
checkInputWidth() {
|
|
169
|
+
const intervalId = setInterval(() => {
|
|
170
|
+
const inputElement = this.$refs.input;
|
|
171
|
+
if (inputElement) {
|
|
172
|
+
const { offsetWidth } = inputElement;
|
|
173
|
+
if (offsetWidth > 0) {
|
|
174
|
+
this.sliderWidth = offsetWidth;
|
|
175
|
+
this.configureTooltip();
|
|
176
|
+
clearInterval(intervalId);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}, 100);
|
|
180
|
+
},
|
|
181
|
+
checkTooltipLabelWidth() {
|
|
182
|
+
const intervalId = setInterval(() => {
|
|
183
|
+
const tooltipLabel = this.$refs.tooltip?.$refs.label;
|
|
184
|
+
if (!tooltipLabel) {
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const { clientWidth } = tooltipLabel;
|
|
189
|
+
if (clientWidth > 0) {
|
|
190
|
+
this.labelWidth = clientWidth;
|
|
191
|
+
this.configureTooltip();
|
|
192
|
+
clearInterval(intervalId);
|
|
193
|
+
}
|
|
194
|
+
}, 100);
|
|
195
|
+
},
|
|
165
196
|
getNewTooltipPosition() {
|
|
166
|
-
|
|
167
|
-
|
|
197
|
+
if (this.sliderWidth === 0 || this.labelWidth === 0) {
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
const halfThumbWidth = 12 / 2;
|
|
201
|
+
const halfLabelWidth = this.labelWidth / 2 || 16;
|
|
168
202
|
const centerPosition = this.sliderWidth / 2;
|
|
169
203
|
|
|
170
204
|
let percentOfRange = (this.sliderVal - this.minValue) / (this.maxValue - this.minValue);
|
|
@@ -175,7 +209,7 @@ export default {
|
|
|
175
209
|
const valuePXPosition = percentOfRange * this.sliderWidth;
|
|
176
210
|
const distFromCenter = valuePXPosition - centerPosition;
|
|
177
211
|
const percentDistFromCenter = distFromCenter / centerPosition;
|
|
178
|
-
const offset = percentDistFromCenter *
|
|
212
|
+
const offset = percentDistFromCenter * halfThumbWidth;
|
|
179
213
|
|
|
180
214
|
const finalLabelPosition = valuePXPosition - halfLabelWidth - offset;
|
|
181
215
|
return finalLabelPosition;
|