summaryrefslogtreecommitdiff
path: root/components/IListView.qml
diff options
context:
space:
mode:
Diffstat (limited to 'components/IListView.qml')
-rw-r--r--components/IListView.qml34
1 files changed, 34 insertions, 0 deletions
diff --git a/components/IListView.qml b/components/IListView.qml
new file mode 100644
index 0000000..d9155f1
--- /dev/null
+++ b/components/IListView.qml
@@ -0,0 +1,34 @@
+import QtQuick
+
+ListView {
+ id: root
+
+ property PropertyAnimation scrollAnim: ISpringAnimation {}
+
+ function scrollToIndex(idx, alignment = ListView.Contain) {
+ root.scrollAnim.stop();
+ let y = root.contentY;
+
+ root.positionViewAtIndex(idx, alignment);
+ let dsty = root.contentY;
+
+ root.contentY = y;
+
+ if (root.scrollAnim) {
+ root.scrollAnim.target = root;
+ root.scrollAnim.property = "contentY";
+ root.scrollAnim.from = y;
+ root.scrollAnim.to = dsty;
+ root.scrollAnim.start();
+ } else
+ root.contentY = dsty;
+ }
+
+ Connections {
+ target: root.scrollAnim
+
+ function onStopped() {
+ // root.positionViewAtIndex(targetIndex, alignment);
+ }
+ }
+}