Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 00e6ceb5249da6496d9fd8ab58530bc2ea047abb
      
https://github.com/WebKit/WebKit/commit/00e6ceb5249da6496d9fd8ab58530bc2ea047abb
  Author: Ahmad Saleem <[email protected]>
  Date:   2026-10-07 (Wed, 07 Oct 2026)

  Changed paths:
    A 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-expected.txt
    A 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-horizontal-expected.txt
    A 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-horizontal.html
    A 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly.html
    M 
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h
    M 
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm

  Log Message:
  -----------
  scroll snap animation taking extremely long to settle
https://bugs.webkit.org/show_bug.cgi?id=321127
rdar://184176304

Reviewed by Frédéric Wang Nélar and Simon Fraser.

On iOS, flicking an overflow scroller with `scroll-snap-type: mandatory` past 
its last snap
position could take multiple seconds to settle back onto that snap position.

With `overscroll-behavior: none`, a fast flick pins the scroller at its maximum 
scroll offset
while the finger still has a large velocity. 
-scrollViewWillEndDragging:withVelocity:targetContentOffset:
then replaced UIKit's target with the closest snap offset, which lies behind 
the current offset,
against the direction of the velocity. UIKit decelerates very slowly towards a 
target like this.

Detect this case after computing the snap target. Stop the momentum by setting 
the target to the
current offset, and once dragging ends, animate to the snap offset with 
-setContentOffset:animated:.
The scroll stays a user interaction until the animation ends, so it still ends 
with exactly one
scrollDidEnd() call (and one scrollend event).

Flicks in either direction past the first or last snap position, on either 
axis, go through this
same check, so neither the vertical nor the horizontal case needs special 
handling. The tests cover
both directions on both axes.

Tests: 
fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-horizontal.html
       
fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly.html

* 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-horizontal-expected.txt:
 Added.
* 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly-horizontal.html:
 Added.
* 
LayoutTests/fast/scrolling/ios/scroll-snap-momentum-against-snap-direction-settles-quickly.html:
 Added.
* 
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.h:
* 
Source/WebKit/UIProcess/RemoteLayerTree/ios/ScrollingTreeScrollingNodeDelegateIOS.mm:
(-[WKScrollingNodeScrollViewDelegate scrollViewWillBeginDragging:]):
(-[WKScrollingNodeScrollViewDelegate 
scrollViewWillEndDragging:withVelocity:targetContentOffset:]):
(-[WKScrollingNodeScrollViewDelegate scrollViewDidEndDragging:willDecelerate:]):
(-[WKScrollingNodeScrollViewDelegate scrollViewDidEndScrollingAnimation:]):

Canonical link: https://commits.webkit.org/323056@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to