Skip to content

Commit

Permalink
fix(core): set wheel event listener to passive for better perf (#971)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghiscoding committed May 12, 2023
1 parent 9175503 commit e4417e8
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/editors/floatEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class FloatEditor extends InputEditor {

if (compositeEditorOptions) {
this._bindEventService.bind(this._input, ['input', 'paste'], this.handleOnInputChange.bind(this) as EventListener);
this._bindEventService.bind(this._input, 'wheel', this.handleOnMouseWheel.bind(this) as EventListener);
this._bindEventService.bind(this._input, 'wheel', this.handleOnMouseWheel.bind(this) as EventListener, { passive: true });
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/common/src/editors/integerEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class IntegerEditor extends InputEditor {

if (compositeEditorOptions) {
this._bindEventService.bind(this._input, ['input', 'paste'], this.handleOnInputChange.bind(this) as EventListener);
this._bindEventService.bind(this._input, 'wheel', this.handleOnMouseWheel.bind(this) as EventListener);
this._bindEventService.bind(this._input, 'wheel', this.handleOnMouseWheel.bind(this) as EventListener, { passive: true });
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/common/src/filters/inputFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ export class InputFilter implements Filter {
// step 2, subscribe to the input event and run the callback when that happens
// also add/remove "filled" class for styling purposes
// we'll use all necessary events to cover the following (keyup, change, mousewheel & spinner)
this._bindEventService.bind(this._filterInputElm, ['keyup', 'blur', 'change', 'wheel'], this.onTriggerEvent.bind(this) as EventListener);
this._bindEventService.bind(this._filterInputElm, ['keyup', 'blur', 'change'], this.onTriggerEvent.bind(this) as EventListener);
this._bindEventService.bind(this._filterInputElm, 'wheel', this.onTriggerEvent.bind(this) as EventListener, { passive: true });
if (this.inputFilterType === 'compound' && this._selectOperatorElm) {
this._bindEventService.bind(this._selectOperatorElm, 'change', this.onTriggerEvent.bind(this) as EventListener);
}
Expand Down
3 changes: 1 addition & 2 deletions packages/common/src/filters/inputMaskFilter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,11 @@ export class InputMaskFilter extends InputFilter {

// step 2, subscribe to the input event and run the callback when that happens
// also add/remove "filled" class for styling purposes
// we'll use all necessary events to cover the following (keyup, change, mousewheel & spinner)
this._bindEventService.bind(this._filterInputElm, ['keyup', 'blur', 'change'], this.onTriggerEvent.bind(this) as EventListener);
}

/**
* Event handler to cover the following (keyup, change, mousewheel & spinner)
* Event handler to cover the following (keyup, blur, change)
* We will trigger the Filter Service callback from this handler
*/
protected onTriggerEvent(event?: MouseEvent | KeyboardEvent, isClearFilterEvent = false) {
Expand Down

0 comments on commit e4417e8

Please sign in to comment.