mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
fix:处理inputRange设置大数页面卡顿问题 (#8651)
This commit is contained in:
parent
f9ef049796
commit
e7f23c9859
@ -383,11 +383,16 @@ export class Range extends React.Component<RangeItemProps, any> {
|
||||
getStepValue(value: number, step: number) {
|
||||
const surplus = value % step;
|
||||
let result = 0;
|
||||
let closeNum = Math.floor(value - (value % step));
|
||||
// 余数 >= 步长一半 -> 向上取
|
||||
// 余数 < 步长一半 -> 向下取
|
||||
const _value = surplus >= step / 2 ? value : safeSub(value, step);
|
||||
while (result <= _value) {
|
||||
result = safeAdd(result, step);
|
||||
if (step < 1 || result === 0 || result === closeNum) {
|
||||
result = safeAdd(result, step);
|
||||
} else {
|
||||
result = closeNum;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user