Skip to content

Commit

Permalink
Merge r220638 - [GTK] stop kinetic scrolling when a zero movement is …
Browse files Browse the repository at this point in the history
…reached

https://bugs.webkit.org/show_bug.cgi?id=175468

Reviewed by Michael Catanzaro.

This is GTK+ change by Christian Hergert.
https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=4f63d839550f7a9038b391e7d3e1e6fc8bdfafa6

When the kinetic scrolling reduces its speed, there can be multiple frames where the movement is zero pixels,
followed by a 1 pixel movement later on. This causes a "jitter" right at the end of the scroll which makes it
feel less quality than other platforms. Instead, we should just clamp it as soon as we get a zero movement.

* platform/ScrollAnimationKinetic.cpp:
(WebCore::ScrollAnimationKinetic::PerAxisData::animateScroll):
  • Loading branch information
carlosgcampos committed Aug 14, 2017
1 parent 1aa7eaf commit d09d005
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
17 changes: 17 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,20 @@
2017-08-13 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] stop kinetic scrolling when a zero movement is reached
https://bugs.webkit.org/show_bug.cgi?id=175468

Reviewed by Michael Catanzaro.

This is GTK+ change by Christian Hergert.
https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=4f63d839550f7a9038b391e7d3e1e6fc8bdfafa6

When the kinetic scrolling reduces its speed, there can be multiple frames where the movement is zero pixels,
followed by a 1 pixel movement later on. This causes a "jitter" right at the end of the scroll which makes it
feel less quality than other platforms. Instead, we should just clamp it as soon as we get a zero movement.

* platform/ScrollAnimationKinetic.cpp:
(WebCore::ScrollAnimationKinetic::PerAxisData::animateScroll):

2017-08-13 Chris Dumez <cdumez@apple.com>

Drop non-const getter for CachedResource::resourceRequest()
Expand Down
4 changes: 3 additions & 1 deletion Source/WebCore/platform/ScrollAnimationKinetic.cpp
Expand Up @@ -81,6 +81,8 @@ ScrollAnimationKinetic::PerAxisData::PerAxisData(double lower, double upper, dou

bool ScrollAnimationKinetic::PerAxisData::animateScroll(Seconds timeDelta)
{
auto lastPosition = m_position;
auto lastTime = m_elapsedTime;
m_elapsedTime += timeDelta;

double exponentialPart = exp(-decelFriction * m_elapsedTime.value());
Expand All @@ -93,7 +95,7 @@ bool ScrollAnimationKinetic::PerAxisData::animateScroll(Seconds timeDelta)
} else if (m_position > m_upper) {
m_position = m_upper;
m_velocity = 0;
} else if (fabs(m_velocity) < 1) {
} else if (fabs(m_velocity) < 1 || (lastTime && fabs(m_position - lastPosition) < 1)) {
m_position = round(m_position);
m_velocity = 0;
}
Expand Down

0 comments on commit d09d005

Please sign in to comment.