Skip to content

Instantly share code, notes, and snippets.

@oKcerG
Created September 19, 2017 23:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oKcerG/935924e85d218594f60b29342b8e48d5 to your computer and use it in GitHub Desktop.
Save oKcerG/935924e85d218594f60b29342b8e48d5 to your computer and use it in GitHub Desktop.
import QtQuick.Controls 2.0
import QtQuick 2.7
import QtQml 2.2
ScrollBar {
id: scrollBar
property ListView listView: parent
stepSize: 1 / listView.count
property real effectiveStep: stepSize * (1 - 0)
size: listView.visibleArea.heightRatio
active: listView.moving || pressed
anchors {
top: parent.top
bottom: parent.bottom
right: parent.right
}
Binding on position {
when: !scrollBar.pressed
value: listView.visibleArea.yPosition
}
Binding {
when: scrollBar.pressed
target: listView
property: "contentY"
value: scrollBar.stepSize ? Math.round(scrollBar.position/effectiveStep) * scrollBar.effectiveStep * listView.contentHeight : scrollBar.position * listView.contentHeight
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment