Skip to content

Commit

Permalink
fix(scroll): prevent wrong offset when the scroll is on the html element
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Molinié committed Oct 11, 2023
1 parent d010378 commit 7e18a10
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/dd-draggable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ export class DDDraggable extends DDBaseImplement implements HTMLElementExtendOpt
const style = this.helper.style;
const { scaleX, scaleY } = Utils.getScaleForElement(this.helper);
const transformParent = Utils.getContainerForPositionFixedElement(this.helper);
const transformParentRect = transformParent.getBoundingClientRect();
// We need to be careful here as the html element actually also includes scroll
// so in this case we always need to ignore it
const transformParentRect = transformParent === document.documentElement ? { top: 0, left: 0 } : transformParent.getBoundingClientRect();
// when an element is scaled, the helper is positioned relative to the first transformed parent, so we need to remove the extra offset
const offsetX = transformParentRect.left;
const offsetY = transformParentRect.top;
Expand Down

0 comments on commit 7e18a10

Please sign in to comment.