Title: [285964] trunk/Source/WebCore
- Revision
- 285964
- Author
- [email protected]
- Date
- 2021-11-17 15:55:47 -0800 (Wed, 17 Nov 2021)
Log Message
Momentum animator: Short scrolls are too far, medium scrolls aren't far enough
https://bugs.webkit.org/show_bug.cgi?id=233272
<rdar://problem/85472653>
Reviewed by Simon Fraser.
* platform/mac/ScrollingEffectsController.mm:
(WebCore::adjustedVelocity):
(WebCore::ScrollingEffectsController::handleWheelEvent):
Attempt to apply a empirically-derived curve to the initial velocity
to fit the distance of a normal momentum scroll.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (285963 => 285964)
--- trunk/Source/WebCore/ChangeLog 2021-11-17 23:53:55 UTC (rev 285963)
+++ trunk/Source/WebCore/ChangeLog 2021-11-17 23:55:47 UTC (rev 285964)
@@ -1,3 +1,17 @@
+2021-11-17 Tim Horton <[email protected]>
+
+ Momentum animator: Short scrolls are too far, medium scrolls aren't far enough
+ https://bugs.webkit.org/show_bug.cgi?id=233272
+ <rdar://problem/85472653>
+
+ Reviewed by Simon Fraser.
+
+ * platform/mac/ScrollingEffectsController.mm:
+ (WebCore::adjustedVelocity):
+ (WebCore::ScrollingEffectsController::handleWheelEvent):
+ Attempt to apply a empirically-derived curve to the initial velocity
+ to fit the distance of a normal momentum scroll.
+
2021-11-17 Alan Bujtas <[email protected]>
[LFC][IFC] Introduce enum class IntrinsicWidthMode
Modified: trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm (285963 => 285964)
--- trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm 2021-11-17 23:53:55 UTC (rev 285963)
+++ trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm 2021-11-17 23:55:47 UTC (rev 285964)
@@ -127,6 +127,28 @@
}
#endif
+static FloatSize adjustedVelocity(FloatSize velocity)
+{
+ auto applyCurve = ^(float originalValue) {
+ if (!originalValue)
+ return originalValue;
+
+ float value = fabs(originalValue);
+ float powerLow = 6.7 * pow(value, -.166);
+ float powerHigh = 36.3 * pow(value, -.392);
+ const float transitionVelocity = 2000;
+
+ auto interpolate = ^(float v0, float v1, float t) {
+ return (1 - t) * v0 + t * v1;
+ };
+
+ float multiplier = interpolate(powerLow, powerHigh, std::min(value, transitionVelocity) / transitionVelocity);
+ return copysign(value * multiplier, originalValue);
+ };
+
+ return { applyCurve(velocity.width()), applyCurve(velocity.height()) };
+}
+
bool ScrollingEffectsController::handleWheelEvent(const PlatformWheelEvent& wheelEvent)
{
if (processWheelEventForScrollSnap(wheelEvent))
@@ -225,7 +247,7 @@
if (!m_momentumScrollInProgress && (momentumPhase == PlatformWheelEventPhase::Began || momentumPhase == PlatformWheelEventPhase::Changed)) {
m_momentumScrollInProgress = true;
if (momentumScrollingAnimatorEnabled()) {
- startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), -wheelEvent.scrollingVelocity(), -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; });
+ startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), -adjustedVelocity(wheelEvent.scrollingVelocity()), -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; });
#if !LOG_DISABLED
m_eventDrivenScrollOffset = m_client.scrollOffset();
m_eventDrivenScrollMomentumStartOffset = m_eventDrivenScrollOffset;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes