Open rs017991 opened 1 year ago
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
0.4.0
master
I'm pretty sure I've tracked down the cause of this:
Scrollable
cursor_position
event
Viewer
origin
position
CursorMoved
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).
Panning behaves the same as when it is not in a Scrollable
Windows
No response
I've retested and confirmed that this issue still exists as of Iced 0.12.
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
Is there an existing issue for this?
Is this issue related to iced?
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
andmaster
, but the reproduction is against master): https://github.com/iced-rs/iced/compare/master...rs017991:iced:image_scrolling_reprodI'm pretty sure I've tracked down the cause of this:
Scrollable
convertscursor_position
into its own coordinate system, yet it passes theevent
itself through untouchedViewer
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 atcursor_position
instead ofposition
: https://github.com/iced-rs/iced/blob/82217947aa80287282ed6deb02d238a31303e0d6/native/src/widget/image/viewer.rs#L250However, a more thorough fix may be to have
Scrollable
tweak theCursorMoved
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