Skip to content

Commit

Permalink
Fix image sometimes scrolling by 1px when clicking inside viewport
Browse files Browse the repository at this point in the history
The max rounding error is +-0.5 so sometimes the rounding error alone caused a movement even if zero new change was requested.
  • Loading branch information
jdpurcell committed Dec 31, 2024
1 parent b22e3e0 commit 0a7cd33
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/scrollhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ void ScrollHelper::move(QPointF delta)
scrollDeltaY = calculateScrollDelta(scrollLocation.y(), vMin, vMax, scrollDeltaY);
}
scrollLocation += QPointF(scrollDeltaX, scrollDeltaY);
int scrollValueX = qRound(scrollLocation.x());
int scrollValueY = qRound(scrollLocation.y());
int scrollValueX = qAbs(scrollLocation.x()) == 0.5 ? 0 : qRound(scrollLocation.x());
int scrollValueY = qAbs(scrollLocation.y()) == 0.5 ? 0 : qRound(scrollLocation.y());
lastMoveRoundingError = QPointF(scrollLocation.x() - scrollValueX, scrollLocation.y() - scrollValueY);
int overscrollDistanceX =
p.shouldConstrain && scrollValueX < hMin ? scrollValueX - hMin :
Expand Down

0 comments on commit 0a7cd33

Please sign in to comment.