Created
March 3, 2017 09:55
-
-
Save 0xlitf/a527b217fa750eb3822f75a249726876 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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