Bug 1259296 - Make sure APZ smooth scroll animations end at their exact destination scroll offset. r=kats
This avoids getting "stuck" at a scroll snap point with wheel scrolling.
MozReview-Commit-ID: 587UC8u1bv0
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -732,16 +732,24 @@ public:
* frame. Returns true if the smooth scroll should be advanced by one frame,
* or false if the smooth scroll has ended.
*/
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) {
nsPoint oneParentLayerPixel =
CSSPoint::ToAppUnits(ParentLayerPoint(1, 1) / aFrameMetrics.GetZoom());
if (mXAxisModel.IsFinished(oneParentLayerPixel.x) &&
mYAxisModel.IsFinished(oneParentLayerPixel.y)) {
+ // Set the scroll offset to the exact destination. If we allow the scroll
+ // offset to end up being a bit off from the destination, we can get
+ // artefacts like "scroll to the next snap point in this direction"
+ // scrolling to the snap point we're already supposed to be at.
+ aFrameMetrics.SetScrollOffset(
+ aFrameMetrics.CalculateScrollRange().ClampPoint(
+ CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetDestination(),
+ mYAxisModel.GetDestination()))));
return false;
}
mXAxisModel.Simulate(aDelta);
mYAxisModel.Simulate(aDelta);
CSSPoint position = CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetPosition(),
mYAxisModel.GetPosition()));