Changeset 285964 in webkit
- Timestamp:
- Nov 17, 2021, 3:55:47 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
platform/mac/ScrollingEffectsController.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r285956 r285964 1 2021-11-17 Tim Horton <timothy_horton@apple.com> 2 3 Momentum animator: Short scrolls are too far, medium scrolls aren't far enough 4 https://bugs.webkit.org/show_bug.cgi?id=233272 5 <rdar://problem/85472653> 6 7 Reviewed by Simon Fraser. 8 9 * platform/mac/ScrollingEffectsController.mm: 10 (WebCore::adjustedVelocity): 11 (WebCore::ScrollingEffectsController::handleWheelEvent): 12 Attempt to apply a empirically-derived curve to the initial velocity 13 to fit the distance of a normal momentum scroll. 14 1 15 2021-11-17 Alan Bujtas <zalan@apple.com> 2 16 -
trunk/Source/WebCore/platform/mac/ScrollingEffectsController.mm
r285953 r285964 128 128 #endif 129 129 130 static FloatSize adjustedVelocity(FloatSize velocity) 131 { 132 auto applyCurve = ^(float originalValue) { 133 if (!originalValue) 134 return originalValue; 135 136 float value = fabs(originalValue); 137 float powerLow = 6.7 * pow(value, -.166); 138 float powerHigh = 36.3 * pow(value, -.392); 139 const float transitionVelocity = 2000; 140 141 auto interpolate = ^(float v0, float v1, float t) { 142 return (1 - t) * v0 + t * v1; 143 }; 144 145 float multiplier = interpolate(powerLow, powerHigh, std::min(value, transitionVelocity) / transitionVelocity); 146 return copysign(value * multiplier, originalValue); 147 }; 148 149 return { applyCurve(velocity.width()), applyCurve(velocity.height()) }; 150 } 151 130 152 bool ScrollingEffectsController::handleWheelEvent(const PlatformWheelEvent& wheelEvent) 131 153 { … … 226 248 m_momentumScrollInProgress = true; 227 249 if (momentumScrollingAnimatorEnabled()) { 228 startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), - wheelEvent.scrollingVelocity(), -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; });250 startMomentumScrollWithInitialVelocity(m_client.scrollOffset(), -adjustedVelocity(wheelEvent.scrollingVelocity()), -wheelEvent.delta(), [](const FloatPoint& targetOffset) { return targetOffset; }); 229 251 #if !LOG_DISABLED 230 252 m_eventDrivenScrollOffset = m_client.scrollOffset();
Note:
See TracChangeset
for help on using the changeset viewer.