提交 5915a736 编写于 作者: Q qiang

fix(App): native component position

上级 de877b71
......@@ -14515,16 +14515,17 @@
function updatePosition() {
const el = rootRef.value;
const rect = el.getBoundingClientRect();
const keys = ["width", "height"];
hidden.value = rect.width === 0 || rect.height === 0;
if (!hidden.value) {
position.position = getFixed(el) ? "absolute" : "static";
const keys = ["top", "left", "width", "height"];
keys.forEach((key) => {
let val = rect[key];
val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val;
position[key] = val + "px";
});
keys.push("top", "left");
}
keys.forEach((key) => {
let val = rect[key];
val = key === "top" ? val + (position.position === "static" ? document.documentElement.scrollTop || document.body.scrollTop || 0 : getNavigationBarHeight()) : val;
position[key] = val + "px";
});
}
let request = null;
function requestPositionUpdate() {
......
......@@ -51,24 +51,25 @@ export function useNative(rootRef: Ref<HTMLElement | null>) {
function updatePosition() {
const el = rootRef.value as HTMLElement
const rect = el.getBoundingClientRect()
const keys: Prop[] = ['width', 'height']
hidden.value = rect.width === 0 || rect.height === 0
if (!hidden.value) {
position.position = getFixed(el) ? 'absolute' : 'static'
const keys: Prop[] = ['top', 'left', 'width', 'height']
keys.forEach((key) => {
let val = rect[key]
val =
key === 'top'
? val +
(position.position === 'static'
? document.documentElement.scrollTop ||
document.body.scrollTop ||
0
: getNavigationBarHeight())
: val
position[key] = val + 'px'
})
keys.push('top', 'left')
}
keys.forEach((key) => {
let val = rect[key]
val =
key === 'top'
? val +
(position.position === 'static'
? document.documentElement.scrollTop ||
document.body.scrollTop ||
0
: getNavigationBarHeight())
: val
position[key] = val + 'px'
})
}
let request: null | number = null
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册