Skip to content

Commit

Permalink
optimize viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
yiminghe committed Mar 17, 2020
1 parent 052d921 commit 1496a2b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "dom-align",
"version": "1.11.0",
"version": "1.11.1",
"description": "Align DOM Node Flexibly ",
"keywords": [
"dom",
Expand Down
9 changes: 6 additions & 3 deletions src/align/alignElement.js
Expand Up @@ -3,8 +3,8 @@ import getOffsetParent from '../getOffsetParent';
import getVisibleRectForElement from '../getVisibleRectForElement';
import getRegion from '../getRegion';

function isOutOfVisibleRect(target) {
const visibleRect = getVisibleRectForElement(target);
function isOutOfVisibleRect(target, alwaysByViewport) {
const visibleRect = getVisibleRectForElement(target, alwaysByViewport);
const targetRegion = getRegion(target);

return (
Expand All @@ -20,7 +20,10 @@ function alignElement(el, refNode, align) {
const target = align.target || refNode;
const refNodeRegion = getRegion(target);

const isTargetNotOutOfVisible = !isOutOfVisibleRect(target);
const isTargetNotOutOfVisible = !isOutOfVisibleRect(
target,
align.overflow && align.overflow.alwaysByViewport,
);

return doAlign(el, refNodeRegion, align, isTargetNotOutOfVisible);
}
Expand Down

0 comments on commit 1496a2b

Please sign in to comment.