Skip to content

Commit 2439b59

Browse files
procotIlya Istomin
andauthored
fix: use Math.ceil() to correctly scroll to fractional coordinates (#785)
Co-authored-by: Ilya Istomin <procot@yandex-team.ru>
1 parent 43bac62 commit 2439b59

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ function smoothScroll(
8181
startY = el.scrollTop
8282
method = (x: number, y: number) => {
8383
// @TODO use Element.scroll if it exists, as it is potentially better performing
84-
el.scrollLeft = x
85-
el.scrollTop = y
84+
// use ceil to include the the fractional part of the number for the scrolling
85+
el.scrollLeft = Math.ceil(x)
86+
el.scrollTop = Math.ceil(y)
8687
}
8788

8889
// scroll looping over a frame if needed

0 commit comments

Comments
 (0)