Skip to content

Add option to pan ScrollView by dragging #2260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Tracked by #1494
mgunyho opened this issue Feb 19, 2023 · 0 comments · Fixed by #8512
Closed
Tracked by #1494

Add option to pan ScrollView by dragging #2260

mgunyho opened this issue Feb 19, 2023 · 0 comments · Fixed by #8512
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS)

Comments

@mgunyho
Copy link

mgunyho commented Feb 19, 2023

Ref #2235

ScrollView has an internal Flickable, with interactive: false. This interactive could be exposed via a public property on the ScrollView (could be called e.g. draggable or pannable), so that the ScrollView can also be panned by dragging the contents if desired. Use case: image viewer that can be panned both with the mouse and with the scroll bars.

A workaround is

scroll := ScrollView {
    HorizontalLayout {
        Rectangle { // this would be the image or whatever you want to pan
            TouchArea {
                moved => {
                    scroll.viewport-x += self.mouse-x - self.pressed-x;
                    scroll.viewport-y += self.mouse-y - self.pressed-y;
                }
            }
        }
    }
}

This looks a bit confusing (at least to me), but it works because moving the viewport also moves the TouchArea, until mouse-x - pressed-x becomes zero. (This simple version doesn't respect the boundaries of the ScrollView, it's possible to pan the inner Rectangle too far.)

@ogoffart ogoffart added the a:flickable The implementation of the Flickable (mO) label Jul 13, 2023
@ogoffart ogoffart added enhancement New feature or request a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) and removed a:flickable The implementation of the Flickable (mO) labels Jan 16, 2024
@ogoffart ogoffart removed the enhancement New feature or request label May 7, 2025
codeshaunted added a commit to codeshaunted/slint that referenced this issue May 22, 2025
ogoffart pushed a commit that referenced this issue May 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants