day8 / re-com

A ClojureScript library of reusable components for Reagent
https://re-com.day8.com.au
MIT License
796 stars 147 forks source link

h-split/v-split jump around when used inside an element with `position: relative` #181

Closed p-himik closed 2 years ago

p-himik commented 5 years ago

h-split and v-split rely on offsetLeft and offsetTop, but these properties are calculated relative to the offsetParent, which is a closes positioned element. And the splits also use clientX and clientY, which are calculated within the viewport. So, if the viewport does not coincide with the closest positioned element, a split's handler will jump on the first mouse move.

Frozenlock commented 5 years ago

Can confirm, bumped my head into the same issue.

MawiraIke commented 2 years ago

I have been able to reproduce this issue and fix it. I have changed the position calculation to be determined by using pageXOffset, pageYOffset and getBoundingClientRect which fix the issue. Thank you for spotting this.