-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normalize delta values on platforms where event.deltaX is 0 even as event.shiftKey is true #48
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
src/utils/normalizeWheel.ts
Outdated
@@ -42,6 +43,12 @@ function normalizeWheel(event: any) { | |||
pX = event.deltaX; | |||
} | |||
|
|||
// on some platforms (e.g. Win10), browsers do not automatically swap deltas for horizontal scroll | |||
if (!isSideScrolling && !event.ctrlKey && event.shiftKey && pX === 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding !isSideScrolling
to try and limit any potential of backward breaking change
@@ -4001,14 +4001,20 @@ | |||
} | |||
}, | |||
"node_modules/caniuse-lite": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's more reasonable to handle it in WheelHandler.js, what do you think?
Line 43 in 65f4548
const normalizedEvent = normalizeWheel(event); |
let normalizedEvent = normalizeWheel(event);
if(navigator.platform !== 'MacIntel' && event.shiftKey){
normalizedEvent = swapWheelAxis(normalizedEvent);
}
const swapWheelAxis = (normalizedEvent)=>{
return {
spinX: normalizedEvent.spinY,
spinY: normalizedEvent.spinX,
pixelX: normalizedEvent.pixelY,
pixelY: normalizedEvent.pixelX,
};
}
Sure - that does sound reasonable and I can def. move it Re: the Thanks for your help :) |
…rizontal scroll in normalizeWheel (certain platforms) chore: npx browserslist@latest --update-db
ed415b3
to
d7af0c4
Compare
🎉 This PR is included in version 3.1.3 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Hi,
The current rsuite-table version has an issue where horizontal scroll with mousewheel + shitKey does not work as expected.
The issue can be reproduced & observed by trying to horizontally scroll tables with the mousewheel (wheel + shift key). The common behavior is to scroll horizontally when the shift key is pressed. For rsuite-table this works on some platforms (notably Mac) but not others (Win).
There's a repro case for rsuite-table (using dom-lib) here:
https://codesandbox.io/s/runtime-star-utr4bh?file=/src/App.js
And a stand-alone repro case for dom-lib showcasing the issue at:
https://codesandbox.io/s/practical-mestorf-6qpp44?file=/src/App.js
Please also ref. the screen recordings below in order to see difference in normalized delta values on Mac vs Windows. Note how the value for
deltaX
stays0
on Windows, incl. whenshiftKey === true
-- this happens across different browsers (tested onChrome, Edge, Firefox):dom-lib deltas on mac
dom-lib deltas on windows
Since dom-lib appears to be normalizing the deltas I'm proposing doing so here instead of in rsuite-table.
I do realize there's more risk involved in doing it here, though, and would be happy to submit a PR for rsuite-table where the values from dom-lib are used if you don't want to pull the change in here.
Thanks,
Trond