mirror of
https://github.com/YACReader/yacreader
synced 2025-06-04 01:28:55 -04:00
Use direct index asigment on item click.
This commit is contained in:
parent
d17aa196b6
commit
82712e0155
@ -148,27 +148,9 @@ Rectangle {
|
|||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
gotoIndex(index);
|
list.currentIndex = index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NumberAnimation {
|
|
||||||
id: anim;
|
|
||||||
target: list;
|
|
||||||
property: "contentX";
|
|
||||||
duration: Math.min(850, Math.max(350, 75 * Math.abs(list.currentIndex - list.previousIndex)))
|
|
||||||
}
|
|
||||||
|
|
||||||
function gotoIndex(idx) {
|
|
||||||
var pos = list.contentX;
|
|
||||||
var destPos;
|
|
||||||
list.previousIndex = list.currentIndex
|
|
||||||
list.positionViewAtIndex(idx, ListView.Beginning);
|
|
||||||
destPos = list.contentX;
|
|
||||||
anim.from = pos;
|
|
||||||
anim.to = destPos;
|
|
||||||
anim.running = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user