Skip to content

Commit

Permalink
fix(Overlay): comment out unnecessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
jdkahn committed Jun 24, 2019
1 parent 9fb3708 commit 52ddf8d
Showing 1 changed file with 27 additions and 21 deletions.
48 changes: 27 additions & 21 deletions src/overlay/utils/position.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,27 +191,33 @@ export default class Position {
}

_makeElementInViewport(pinElement, number, type, isPinFixed) {
let result = number;
const docElement = document.documentElement;
const offsetParent =
pinElement.offsetParent || document.documentElement;

if (result < 0) {
if (isPinFixed) {
result = 0;
} else if (
offsetParent === document.body &&
dom.getStyle(offsetParent, 'position') === 'static'
) {
// Only when div's offsetParent is document.body, we set new position result.
result = Math.max(
docElement[`scroll${type}`],
document.body[`scroll${type}`]
);
}
}

return result;
// pinElement.offsetParent is never body because wrapper has position: absolute
// refactored to make code clearer. Revert if wrapper style changes.

// let result = number;
// const docElement = document.documentElement;
// const offsetParent =
// pinElement.offsetParent || document.documentElement;

// if (result < 0) {
// if (isPinFixed) {
// result = 0;
// }

// else if (
// offsetParent === document.body &&
// dom.getStyle(offsetParent, 'position') === 'static'
// ) {
// // Only when div's offsetParent is document.body, we set new position result.
// result = Math.max(
// docElement[`scroll${type}`],
// document.body[`scroll${type}`]
// );
// }
// }
// return result;

return number < 0 && isPinFixed ? 0 : number;
}

_normalizePosition(element, align, isPinFixed) {
Expand Down

0 comments on commit 52ddf8d

Please sign in to comment.