Skip to content

Commit 0823ff3

Browse files
committed
Fix sticky top
1 parent 581ffc6 commit 0823ff3

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

resources/js/components/StickyTop.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
const stuck = computed(() => {
1212
const style = el.value ? window.getComputedStyle(el.value) : null;
1313
const { bottom, top } = selfRect;
14+
const round = (num:number) => Math.round((num + Number.EPSILON) * 100) / 100;
1415
return el.value
1516
&& style.position === 'sticky'
1617
&& bottom >= 0
17-
&& top <= parseFloat(style.top);
18+
&& round(top) <= round(parseFloat(style.top));
1819
});
1920
const isOverflowingViewport = ref(false);
2021
const { height: innerHeight } = useWindowSize();

0 commit comments

Comments
 (0)