Skip to content
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

解决浏览器窗口缩小到一定比例,scrollLeft(scrollDistance + 1)不生效问题 #3

Open
flym1013 opened this issue Oct 30, 2023 · 0 comments

Comments

@flym1013
Copy link

浏览器缩放的时候,scrollLeft+ 1会被设置成 1 * window.devicePixelRatio, 如果结果小于1就会被判定成+ 0, 所以需要保证每次变化的值大于1
const ratio = parseFloat((1 / window.devicePixelRatio).toFixed(2) ) + 0.01 // + 0.01 为了保证 ratio >= 1
dom1.scrollLeft= dom1.scrollLeft+ ratio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant