mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_widget_numeric_step: throttle update calls when scrolling on field
Before this changes, when scrolling on a field, the price update was collapsed because lots of calls to the function was made in a few seconds. With this changes, the field update, when using the scroll is limited to 1 each 0,1 seconds and the info is updated correctly.
This commit is contained in:
@@ -22,10 +22,19 @@ export class NumericStep extends FloatField {
|
||||
}
|
||||
_onWheel(ev) {
|
||||
ev.preventDefault();
|
||||
if (ev.deltaY > 0) {
|
||||
this._doStep("minus");
|
||||
} else {
|
||||
this._doStep("plus");
|
||||
if (!this._lastWheelTime) {
|
||||
this._lastWheelTime = 0;
|
||||
}
|
||||
const now = Date.now();
|
||||
const throttleLimit = 100;
|
||||
if (now - this._lastWheelTime >= throttleLimit) {
|
||||
this._lastWheelTime = now;
|
||||
|
||||
if (ev.deltaY > 0) {
|
||||
this._doStep("minus");
|
||||
} else {
|
||||
this._doStep("plus");
|
||||
}
|
||||
}
|
||||
}
|
||||
updateField(val) {
|
||||
|
||||
Reference in New Issue
Block a user