Skip to content

Commit

Permalink
removign unneccessary pixel location manipulation
Browse files Browse the repository at this point in the history
  • Loading branch information
dpitcock committed Feb 6, 2025
1 parent c7cb8a8 commit a51ee04
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/container/use-sticky-header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export const useStickyHeader = (
}
if (rootRef.current && headerRef.current) {
const rootTopBorderWidth = parseFloat(getComputedStyle(rootRef.current).borderTopWidth) || 0;
//using Math.round to adjust for rounding errors in floating-point arithmetic and timing issues
const rootTop = Math.round((rootRef.current.getBoundingClientRect().top + rootTopBorderWidth) * 10000) / 10000;
const headerTop = Math.round(headerRef.current.getBoundingClientRect().top * 10000) / 10000;
// Using Math.round to adjust for rounding errors in floating-point arithmetic and timing issues
const rootTop = Math.round(rootRef.current.getBoundingClientRect().top + rootTopBorderWidth);
const headerTop = Math.round(headerRef.current.getBoundingClientRect().top);
if (rootTop < headerTop) {
setIsStuck(true);
} else {
Expand Down

0 comments on commit a51ee04

Please sign in to comment.