Skip to content

Commit

Permalink
fix: add detection conditions of whether to correct the position
Browse files Browse the repository at this point in the history
  • Loading branch information
zjffun committed Oct 30, 2020
1 parent 6d47ac3 commit 9d759a6
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions packages/utils/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,28 +215,29 @@ function getRect(
// Not needed on <= IE11
if (!IE11OrLess) {
do {
if (
container &&
container.getBoundingClientRect &&
if (container && container.getBoundingClientRect) {
//@ts-ignore
(css(container, "transform") !== "none" ||
(relativeToNonStaticParent &&
//@ts-ignore
css(container, "position") !== "static"))
) {
let containerRect = container.getBoundingClientRect();

// Set relative to edges of padding box of container
top -=
//@ts-ignore
containerRect.top + parseInt(css(container, "border-top-width"));
left -=
//@ts-ignore
containerRect.left + parseInt(css(container, "border-left-width"));
bottom = top + elRect.height;
right = left + elRect.width;

break;
const containerStyle = css(container);
if (
(containerStyle.transform && containerStyle.transform !== "none") ||
(containerStyle.perspective &&
containerStyle.perspective !== "none") ||
(containerStyle.filter && containerStyle.filter !== "none") ||
(relativeToNonStaticParent && containerStyle.position !== "static")
) {
let containerRect = container.getBoundingClientRect();

// Set relative to edges of padding box of container
top -=
containerRect.top + parseInt(containerStyle["border-top-width"]);
left -=
containerRect.left +
parseInt(containerStyle["border-left-width"]);
bottom = top + elRect.height;
right = left + elRect.width;

break;
}
}
/* jshint boss:true */
} while ((container = container.parentNode));
Expand Down

0 comments on commit 9d759a6

Please sign in to comment.