Skip to content

Commit

Permalink
fix(dom): vertical getPointerPosition value (#6864)
Browse files Browse the repository at this point in the history
From my understand, in the changes #5773, the Y position of all the
boxes is already calculated and accounted for in the offsetY value we
get. However, because the HTML coordinate system has Y=0 at the top,
when we do offsetY/boxH, we get a position relative to the top of the
element. However, we expect that position relative to the "start" of the
slider, or the bottom of it. Therefore, we want to get the inverse
value, which is '1 - clamp(offsetY/boxH)'.

Fixes #6863
  • Loading branch information
gkatsev authored Oct 1, 2020
1 parent f22ead1 commit 1963086
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/utils/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ export function getPointerPosition(el, event) {
offsetY = event.changedTouches[0].pageY + box.top;
}

position.y = Math.max(0, Math.min(1, (offsetY + boxH) / boxH));
position.y = (1 - Math.max(0, Math.min(1, offsetY / boxH)));
position.x = Math.max(0, Math.min(1, offsetX / boxW));
return position;
}
Expand Down

0 comments on commit 1963086

Please sign in to comment.