Skip to content

Commit bb81009

Browse files
kaustuvpokharelgabriel-bolbotina
authored andcommitted
implemented scrollbar for all scrollview
1 parent e702b7e commit bb81009

1 file changed

Lines changed: 23 additions & 3 deletions

File tree

app/qml/components/MMScrollView.qml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,29 @@ import QtQuick.Controls
1616
ScrollView {
1717
id: root
1818

19-
contentWidth: availableWidth // to only scroll vertically
19+
readonly property bool isMobile: (Qt.platform.os === "android" || Qt.platform.os === "ios")
20+
property int scrollSpace: !isMobile ? 10 : 0
2021

21-
ScrollBar.vertical.policy: ScrollBar.AlwaysOff
22-
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
22+
contentWidth: availableWidth - scrollSpace // to only scroll vertically
23+
24+
ScrollBar.horizontal: null
25+
26+
ScrollBar.vertical: ScrollBar {
27+
id: verticalScrollBar
28+
29+
policy: ScrollBar.AsNeeded
30+
visible: !isMobile && (root.contentHeight > root.height)
31+
opacity: (pressed || root.moving) ? 0.7 : 0.4
32+
33+
anchors.right: root.right
34+
35+
implicitHeight: root.height
36+
37+
contentItem: Rectangle {
38+
implicitWidth: 5
39+
radius: width / 2
40+
color: __style.darkGreenColor
41+
}
42+
}
2343

2444
}

0 commit comments

Comments
 (0)