iced
iced copied to clipboard
Glitch Panning Image in Scrollable
Is there an existing issue for this?
- [X] I have searched the existing issues.
Is this issue related to iced?
- [X] My hardware is compatible and my graphics drivers are up-to-date.
What happened?
When you have an Image Viewer within a Scrollable, panning on the zoomed-in image causes it to jump wildly upwards.
This does not happen if the scroll bar is all the way at the top; the further you scroll down, the more pronounced the jump is.
You can reproduce this by running this slightly-tweaked example:
(I've encountered this in both 0.4.0
and master
, but the reproduction is against master):
https://github.com/iced-rs/iced/compare/master...rs017991:iced:image_scrolling_reprod
I'm pretty sure I've tracked down the cause of this:
- When passing events,
Scrollable
convertscursor_position
into its own coordinate system, yet it passes theevent
itself through untouched - As a result,
Viewer
ends up calculating its delta based on two different coordinate systems:origin
is based on the convertedcursor_position
, whereasposition
comes from the untouchedCursorMoved
event.
You could fix Viewer
by changing this line to point at cursor_position
instead of position
:
https://github.com/iced-rs/iced/blob/82217947aa80287282ed6deb02d238a31303e0d6/native/src/widget/image/viewer.rs#L250
However, a more thorough fix may be to have Scrollable
tweak the CursorMoved
event (as well as any others that include coordinate data).
What is the expected behavior?
Panning behaves the same as when it is not in a Scrollable
Version
master
Operative System
Windows
Do you have any log output?
No response
I've retested and confirmed that this issue still exists as of Iced 0.12
.
See also my reproduction, rebased onto 0.12
:
https://github.com/iced-rs/iced/compare/0.12...rs017991:iced:image_scrolling_reprod-0.12