Giter Site home page Giter Site logo

Comments (1)

jinzhubaofu avatar jinzhubaofu commented on August 24, 2024

经查,造成此问题的原因是lib.dom.getPosition()方法中使用了element.getBoundingClientRect()方法。而此方法可能会返回带小数的547.5的left或top值。

在返回时,使用了left | 0的处理,此处为什么要除去小数部分我不是很清楚。总之是这被抹去的小数部分引起了这个偏差。

我不知道诸如left这样可以设置数值的样式,究竟可以设定什么样精度的小数,是否在各浏览器上有所差异。可能需要做做实验。

getBoundingClientRect给出的数值和样式数值是不是同样的精度呢?如果是一样的那就不用抹掉小数部分,直接给糊上去就行了。

from zxui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.