moveable: Subpixel values are rounded causing misalignment

Environments

  • Framework name: react-moveable
  • Framework version: 0.16.2

Description

The offsetLeft/offsetTop unfortunately round the actual offsets. Hence, a style="left: 17.85px" becomes offsetLeft == 18. This occasionally causes visible misalignment. This is a bit even more difficult given that sometimes getBoundingClientRect() is used for some operations, which is fractional, like here.

This could be addressed by using getBoundingClientRect() everywhere. However, getBCR is not always equivalent to offsetLeft/Top. The difference between these two is not very common though.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Comments: 20 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@daybrush sorry, should have done it before, here it is https://codesandbox.io/s/moveable-alignement-b5ynwi (I added transform so it’s a bit more visible

This appears the issue with Chrome rounding the height/width. I filed https://bugs.chromium.org/p/chromium/issues/detail?id=1049374