Index: Source/platform/scroll/ScrollAnimatorNone.cpp |
diff --git a/Source/platform/scroll/ScrollAnimatorNone.cpp b/Source/platform/scroll/ScrollAnimatorNone.cpp |
index 4a24201241b5a35b37f3c3de5060472d319feafb..3a4e7ed612ec125298409c4e4f983f0f837d8ffb 100644 |
--- a/Source/platform/scroll/ScrollAnimatorNone.cpp |
+++ b/Source/platform/scroll/ScrollAnimatorNone.cpp |
@@ -324,6 +324,17 @@ bool ScrollAnimatorNone::PerAxisData::updateDataFromParameters(float step, float |
return true; |
} |
+inline double ScrollAnimatorNone::PerAxisData::newScrollAnimationPosition(double deltaTime) |
+{ |
+ if (deltaTime < m_attackTime) |
+ return attackCurve(m_attackCurve, deltaTime, m_attackTime, m_startPosition, m_attackPosition); |
+ if (deltaTime < (m_animationTime - m_releaseTime)) |
+ return m_attackPosition + (deltaTime - m_attackTime) * m_desiredVelocity; |
+ // release is based on targeting the exact final position. |
+ double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime); |
+ return releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition); |
+} |
+ |
// FIXME: Add in jank detection trace events into this function. |
bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime) |
{ |
@@ -334,23 +345,13 @@ bool ScrollAnimatorNone::PerAxisData::animateScroll(double currentTime) |
m_lastAnimationTime = currentTime; |
double deltaTime = currentTime - m_startTime; |
- double newPosition = *m_currentPosition; |
if (deltaTime > m_animationTime) { |
*m_currentPosition = m_desiredPosition; |
reset(); |
return false; |
} |
- if (deltaTime < m_attackTime) |
- newPosition = attackCurve(m_attackCurve, deltaTime, m_attackTime, m_startPosition, m_attackPosition); |
- else if (deltaTime < (m_animationTime - m_releaseTime)) |
- newPosition = m_attackPosition + (deltaTime - m_attackTime) * m_desiredVelocity; |
- else { |
- // release is based on targeting the exact final position. |
- double releaseDeltaT = deltaTime - (m_animationTime - m_releaseTime); |
- newPosition = releaseCurve(m_releaseCurve, releaseDeltaT, m_releaseTime, m_releasePosition, m_desiredPosition); |
- } |
- |
+ double newPosition = newScrollAnimationPosition(deltaTime); |
// Normalize velocity to a per second amount. Could be used to check for jank. |
if (lastScrollInterval > 0) |
m_currentVelocity = (newPosition - *m_currentPosition) / lastScrollInterval; |