Skip to content

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

Description

@flym1013

浏览器缩放的时候,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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions