Skip to content

Instantly share code, notes, and snippets.

@0xlitf
Created March 3, 2017 09:55
Show Gist options
  • Save 0xlitf/a527b217fa750eb3822f75a249726876 to your computer and use it in GitHub Desktop.
Save 0xlitf/a527b217fa750eb3822f75a249726876 to your computer and use it in GitHub Desktop.
Rectangle {
id: scrollBar
visible: gridView.contentHeight > gridView.height
height: parent.height
width: 20
color: "#0fffffff"
radius: 2
anchors {
top: parent.top
right: parent.right
}
Rectangle {
id: scrollLine
width: parent.width
height: gridView.height * gridView.height / gridView.contentHeight
color: "#3fffffff"
radius: width / 4
y: (gridView.contentY / (gridView.contentHeight - gridView.height)) * (scrollBar.height - scrollLine.height)
MouseArea {
anchors.fill: parent
drag {
target: scrollLine
minimumY: 0
maximumY: scrollBar.height - scrollLine.height
axis: Drag.YAxis
}
onMouseYChanged: {
gridView.contentY = scrollLine.y / (scrollBar.height - scrollLine.height) * (gridView.contentHeight - gridView.height)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment