-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
feat: Support inverted horizontal scrolling for right-to-left locales #787
Conversation
packages/virtual-core/src/index.ts
Outdated
offset = element[instance.options.horizontal ? 'scrollLeft' : 'scrollTop'] | ||
const { horizontal, isRtl } = instance.options | ||
offset = horizontal | ||
? element['scrollLeft'] * (isRtl && -1 || 1) |
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.
Let's keep it simple
? element['scrollLeft'] * (isRtl && -1 || 1) | |
? element['scrollLeft'] * (isRtl ? -1 : 1) |
Did you test it on all modern browsers?
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.
We are used to adhering to ESlint's rules regarding ternaries: https://eslint.org/docs/latest/rules/no-nested-ternary
The scenario in the included videos was tested in Safari, Chrome, Firefox, Brave, Opera, and Edge.
☁️ Nx Cloud ReportCI is running/has finished running commands for commit c257810. As they complete they will appear below. Click to see the status, the terminal output, and the build insights. 📂 See all runs for this CI Pipeline Execution ✅ Successfully ran 2 targetsSent with 💌 from NxCloud. |
Thanks @cachgill 🙌 |
This change adds an option for consumers who need to switch between left-to-right and right-to-left language locales.
With this change, scrolling left-to-right:
https://github.com/user-attachments/assets/93892f15-a5fe-4cdc-8ccf-45c316a966f0
Without this change, scrolling right-to-left:
https://github.com/user-attachments/assets/47aa1cae-de3d-4946-9fd8-29fee19fe560
With this change, scrolling right-to-left:
https://github.com/user-attachments/assets/ab87e0f7-0679-4669-986d-69188d572f7f