Skip to content
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

Add option to pan ScrollView by dragging #2260

Open
mgunyho opened this issue Feb 19, 2023 · 0 comments
Open

Add option to pan ScrollView by dragging #2260

mgunyho opened this issue Feb 19, 2023 · 0 comments
Labels
a:widgets Implementation of widgets (from std-widgets.slint) and their styles (mF,bS) enhancement New feature or request

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
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) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants