chore: optimize some code (#9669)

This commit is contained in:
neverland
2021-10-12 20:41:45 +08:00
committed by GitHub
parent d5b3350ee5
commit 477017a4ba
6 changed files with 41 additions and 58 deletions
+1 -11
View File
@@ -100,16 +100,6 @@ export default defineComponent({
}
});
const getScrollerRect = () => {
if ('getBoundingClientRect' in scrollParent.value!) {
return useRect(scrollParent);
}
return {
top: 0,
left: 0,
};
};
const getActiveAnchor = (
scrollTop: number,
rects: Array<{ top: number; height: number }>
@@ -133,7 +123,7 @@ export default defineComponent({
const { sticky, indexList } = props;
const scrollTop = getScrollTop(scrollParent.value!);
const scrollParentRect = getScrollerRect();
const scrollParentRect = useRect(scrollParent);
const rects = children.map((item) =>
item.getRect(scrollParent.value, scrollParentRect)