fix(handleWheel): mouse scrolling behavior for out-of-focus windows#2992
Conversation
3476a90 to
b39d1c9
Compare
There was a problem hiding this comment.
While that works, I find the logic quite convoluted.
How about the following:
unbindEvents() {
...
// Kept for backward compatibility purpose
publicAPI.setContainer(null);
}
setContainer(newContainer) {
if (newContainer === model.container) {
return false;
}
unbindEvents();
model.container = newContainer;
bindEvents();
return true;
}
// container parameter is for backward compatibility purpose
bindEvents(container = model.container){
if (model.container != container) {
setContainer(container)
return;
}
...
}
...
publicAPI.delete(
...
setContainer(null);
}
And to not forget about modified() and _onContainerChanged() (see macro.js::findSetter(),
setContainer(newContainer) {
if (newContainer === model.container) {
return false;
}
unbindEvents();
const res = superclass.setContainer(newContainer);
bindEvents(model.container);
return res;
}
...
macro.setGet(...[container]);
|
Oh yes, thanks for reminding about I don't agree on the new call tree you suggested. It is more complex to my eyes. Specially since |
16deccc to
4731fad
Compare
floryst
left a comment
There was a problem hiding this comment.
One last change needed: the getContainer() type needs to be updated to be getContainer(): Nullable<HTMLElement>. You can also update the setContainer type to use Nullable for consistency.
When rebinding events with a different container, make sure all timeouts and state variables from previous containter are cleared.
4731fad to
dae07b6
Compare
|
LGTM |
|
🎉 This PR is included in version 29.4.5 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Brief Description
When rebinding events with a different container, make sure all timeouts and state variables from previous container are cleared.
This PR is part of a react-vtk-js fix for out-of-focus wheel events (Kitware/react-vtk-js#125)
Context
Results
Changes
PR and Code Checklist
npm run reformatto have correctly formatted codeTesting
This change adds or fixes unit tests