diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2026-09-02 18:26:45 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2026-09-02 18:26:45 +0800 |
| commit | f7a43077fe4e139dd7e3f46f448e0951740ec148 (patch) | |
| tree | f6a68248fe42bd899e99049bab7fdb7e5d26ea60 /components/IListView.qml | |
| parent | 2f7576faf493b4667b02dcb60ddbf3aa0a9f654b (diff) | |
fix: qmlfmt
IListView: animation
Diffstat (limited to 'components/IListView.qml')
| -rw-r--r-- | components/IListView.qml | 34 |
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); + } + } +} |
