mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
fix(console): axis calculations in use-position hook
This commit is contained in:
parent
b8916adea9
commit
331eec5fd7
1 changed files with 6 additions and 8 deletions
|
@ -196,12 +196,11 @@ export default function usePosition({
|
||||||
|
|
||||||
const anchorRect = anchorRef.current.getBoundingClientRect();
|
const anchorRect = anchorRef.current.getBoundingClientRect();
|
||||||
const overlayRect = overlayRef.current.getBoundingClientRect();
|
const overlayRect = overlayRef.current.getBoundingClientRect();
|
||||||
const { scrollTop, scrollLeft } = document.documentElement;
|
|
||||||
|
|
||||||
const verticalTop = anchorRect.y - overlayRect.height + scrollTop - offset.vertical;
|
const verticalTop = anchorRect.y - overlayRect.height - offset.vertical;
|
||||||
const verticalCenter =
|
const verticalCenter =
|
||||||
anchorRect.y - anchorRect.height / 2 - overlayRect.height / 2 + scrollTop + offset.vertical;
|
anchorRect.y - anchorRect.height / 2 - overlayRect.height / 2 + offset.vertical;
|
||||||
const verticalBottom = anchorRect.y + anchorRect.height + scrollTop + offset.vertical;
|
const verticalBottom = anchorRect.y + anchorRect.height + offset.vertical;
|
||||||
|
|
||||||
const verticalPositionMap = {
|
const verticalPositionMap = {
|
||||||
top: verticalTop,
|
top: verticalTop,
|
||||||
|
@ -209,11 +208,10 @@ export default function usePosition({
|
||||||
bottom: verticalBottom,
|
bottom: verticalBottom,
|
||||||
};
|
};
|
||||||
|
|
||||||
const horizontalStart = anchorRect.x + scrollLeft + offset.horizontal;
|
const horizontalStart = anchorRect.x + offset.horizontal;
|
||||||
const horizontalCenter =
|
const horizontalCenter =
|
||||||
anchorRect.x + anchorRect.width / 2 - overlayRect.width / 2 + scrollLeft + offset.horizontal;
|
anchorRect.x + anchorRect.width / 2 - overlayRect.width / 2 + offset.horizontal;
|
||||||
const horizontalEnd =
|
const horizontalEnd = anchorRect.x + anchorRect.width - overlayRect.width + offset.horizontal;
|
||||||
anchorRect.x + anchorRect.width - overlayRect.width + scrollLeft + offset.horizontal;
|
|
||||||
|
|
||||||
const horizontalPositionMap = {
|
const horizontalPositionMap = {
|
||||||
start: horizontalStart,
|
start: horizontalStart,
|
||||||
|
|
Loading…
Reference in a new issue