@sheinx/hooks 3.9.12-beta.5 → 3.9.12-beta.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slider.d.ts","sourceRoot":"","sources":["use-slider.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4CxD,eAAO,MAAM,SAAS;;
|
|
1
|
+
{"version":3,"file":"use-slider.d.ts","sourceRoot":"","sources":["use-slider.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4CxD,eAAO,MAAM,SAAS;;kCA4Ja,gBAAgB;gCAIlB,gBAAgB;8BAKL,gBAAgB;;;;;;;;;;;;;;;;;;;CA2E3D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -149,8 +149,42 @@ var useSlider = exports.useSlider = function useSlider(props) {
|
|
|
149
149
|
// Check if the new value would be disabled
|
|
150
150
|
var newValue = getValueFromRate(newRate[context.dragIndex], scale, step);
|
|
151
151
|
if (isDisabled(newValue)) {
|
|
152
|
-
//
|
|
153
|
-
|
|
152
|
+
// Binary search for the closest allowed boundary in the drag direction
|
|
153
|
+
var currentRate = v;
|
|
154
|
+
var lo, hi, boundaryRate;
|
|
155
|
+
if (rate > currentRate) {
|
|
156
|
+
// Dragging forward: find the largest non-disabled rate in [currentRate, rate]
|
|
157
|
+
lo = currentRate;
|
|
158
|
+
hi = rate;
|
|
159
|
+
for (var i = 0; i < 20; i++) {
|
|
160
|
+
var mid = (lo + hi) / 2;
|
|
161
|
+
if (isDisabled(getValueFromRate(mid, scale, step))) {
|
|
162
|
+
hi = mid;
|
|
163
|
+
} else {
|
|
164
|
+
lo = mid;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
boundaryRate = lo;
|
|
168
|
+
} else {
|
|
169
|
+
// Dragging backward: find the smallest non-disabled rate in [rate, currentRate]
|
|
170
|
+
lo = rate;
|
|
171
|
+
hi = currentRate;
|
|
172
|
+
for (var _i = 0; _i < 20; _i++) {
|
|
173
|
+
var _mid = (lo + hi) / 2;
|
|
174
|
+
if (isDisabled(getValueFromRate(_mid, scale, step))) {
|
|
175
|
+
lo = _mid;
|
|
176
|
+
} else {
|
|
177
|
+
hi = _mid;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
boundaryRate = hi;
|
|
181
|
+
}
|
|
182
|
+
var boundaryValue = getValueFromRate(boundaryRate, scale, step);
|
|
183
|
+
var currentValue = getValueFromRate(v, scale, step);
|
|
184
|
+
if (isDisabled(boundaryValue) || boundaryValue === currentValue) {
|
|
185
|
+
return r;
|
|
186
|
+
}
|
|
187
|
+
newRate[context.dragIndex] = boundaryRate;
|
|
154
188
|
}
|
|
155
189
|
if (newRate[0] > newRate[1]) {
|
|
156
190
|
context.dragIndex = context.dragIndex === 0 ? 1 : 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-slider.d.ts","sourceRoot":"","sources":["use-slider.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4CxD,eAAO,MAAM,SAAS;;
|
|
1
|
+
{"version":3,"file":"use-slider.d.ts","sourceRoot":"","sources":["use-slider.ts"],"names":[],"mappings":";AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AA4CxD,eAAO,MAAM,SAAS;;kCA4Ja,gBAAgB;gCAIlB,gBAAgB;8BAKL,gBAAgB;;;;;;;;;;;;;;;;;;;CA2E3D,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -142,8 +142,42 @@ export var useSlider = function useSlider(props) {
|
|
|
142
142
|
// Check if the new value would be disabled
|
|
143
143
|
var newValue = getValueFromRate(newRate[context.dragIndex], scale, step);
|
|
144
144
|
if (isDisabled(newValue)) {
|
|
145
|
-
//
|
|
146
|
-
|
|
145
|
+
// Binary search for the closest allowed boundary in the drag direction
|
|
146
|
+
var currentRate = v;
|
|
147
|
+
var lo, hi, boundaryRate;
|
|
148
|
+
if (rate > currentRate) {
|
|
149
|
+
// Dragging forward: find the largest non-disabled rate in [currentRate, rate]
|
|
150
|
+
lo = currentRate;
|
|
151
|
+
hi = rate;
|
|
152
|
+
for (var i = 0; i < 20; i++) {
|
|
153
|
+
var mid = (lo + hi) / 2;
|
|
154
|
+
if (isDisabled(getValueFromRate(mid, scale, step))) {
|
|
155
|
+
hi = mid;
|
|
156
|
+
} else {
|
|
157
|
+
lo = mid;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
boundaryRate = lo;
|
|
161
|
+
} else {
|
|
162
|
+
// Dragging backward: find the smallest non-disabled rate in [rate, currentRate]
|
|
163
|
+
lo = rate;
|
|
164
|
+
hi = currentRate;
|
|
165
|
+
for (var _i = 0; _i < 20; _i++) {
|
|
166
|
+
var _mid = (lo + hi) / 2;
|
|
167
|
+
if (isDisabled(getValueFromRate(_mid, scale, step))) {
|
|
168
|
+
lo = _mid;
|
|
169
|
+
} else {
|
|
170
|
+
hi = _mid;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
boundaryRate = hi;
|
|
174
|
+
}
|
|
175
|
+
var boundaryValue = getValueFromRate(boundaryRate, scale, step);
|
|
176
|
+
var currentValue = getValueFromRate(v, scale, step);
|
|
177
|
+
if (isDisabled(boundaryValue) || boundaryValue === currentValue) {
|
|
178
|
+
return r;
|
|
179
|
+
}
|
|
180
|
+
newRate[context.dragIndex] = boundaryRate;
|
|
147
181
|
}
|
|
148
182
|
if (newRate[0] > newRate[1]) {
|
|
149
183
|
context.dragIndex = context.dragIndex === 0 ? 1 : 0;
|