File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -222,11 +222,18 @@ function polyfill() {
222222 method = scrollElement ;
223223 }
224224
225- const maxDistance = Math . max ( Math . abs ( x - startX ) , Math . abs ( y - startY ) ) ;
226- const scrollTime = Math . max (
225+ // Calculate the maximum distance to scroll in pixels
226+ const distanceToScrollX = Math . abs ( x - startX ) ;
227+ const distanceToScrollY = Math . abs ( y - startY ) ;
228+ const maxDistanceToScroll = Math . max ( distanceToScrollX , distanceToScrollY ) ;
229+ // Configure the speed animation in pixels/ms
230+ const animationSpeed = 1 ;
231+ // Calculate the time needed for the scroll animation
232+ const scrollTime =
233+ Math . max (
227234 MIN_SCROLL_TIME ,
228- Math . min ( MAX_SCROLL_TIME , maxDistance )
229- ) ;
235+ Math . min ( MAX_SCROLL_TIME , maxDistanceToScroll )
236+ ) * animationSpeed ;
230237
231238 // scroll looping over a frame
232239 step ( {
@@ -262,8 +269,8 @@ function polyfill() {
262269 arguments [ 0 ] . top !== undefined
263270 ? arguments [ 0 ] . top
264271 : arguments [ 1 ] !== undefined
265- ? arguments [ 1 ]
266- : w . scrollY || w . pageYOffset
272+ ? arguments [ 1 ]
273+ : w . scrollY || w . pageYOffset
267274 ) ;
268275
269276 return ;
You can’t perform that action at this time.
0 commit comments