summaryrefslogtreecommitdiff
path: root/components/IListView.qml
blob: d9155f1b6fa8314acf7aa6055475a8c1acfc70a2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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);
		}
	}
}