mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-20 00:30:36 +03:00
fix: popup doesn't reposition when scrolling in Firefox (#427)
This commit is contained in:
+10
-5
@@ -53,13 +53,18 @@ export function getRelativePosition(el, targetWidth, targetHeight, fixed) {
|
|||||||
return { left: `${left}px`, top: `${top}px` };
|
return { left: `${left}px`, top: `${top}px` };
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getScrollParent(node, until = document) {
|
export function getScrollParent(node, until = document.body) {
|
||||||
if (!node || node === until) {
|
if (!node || node === until) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node.scrollHeight > node.clientHeight) {
|
const style = (value, prop) => getComputedStyle(value, null).getPropertyValue(prop);
|
||||||
return node;
|
|
||||||
}
|
const regex = /(auto|scroll)/;
|
||||||
return getScrollParent(node.parentNode, until);
|
|
||||||
|
const scroll = regex.test(
|
||||||
|
style(node, 'overflow') + style(node, 'overflow-y') + style(node, 'overflow-x')
|
||||||
|
);
|
||||||
|
|
||||||
|
return scroll ? node : getScrollParent(node.parentNode, until);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user