修复top=0的组件无法吸附问题
This commit is contained in:
@@ -105,9 +105,7 @@ const stickyTop = computed(() => {
|
||||
|
||||
// 获取sticky元素的位置信息,并更新rect
|
||||
function getRect() {
|
||||
nextTick(() => {
|
||||
setTimeout(
|
||||
() => {
|
||||
const next = () => {
|
||||
uni.createSelectorQuery()
|
||||
.in(proxy)
|
||||
.select(".cl-sticky")
|
||||
@@ -127,10 +125,17 @@ function getRect() {
|
||||
// top需要减去offsetTop并加上当前滚动距离,保证吸顶准确
|
||||
rect.top = (node.top ?? 0) - props.offsetTop + scrollTop.value;
|
||||
});
|
||||
},
|
||||
isHarmony() ? 300 : 0
|
||||
);
|
||||
};
|
||||
|
||||
if (isHarmony()) {
|
||||
nextTick(() => {
|
||||
setTimeout(() => {
|
||||
next();
|
||||
}, 300);
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
|
||||
Reference in New Issue
Block a user