mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
divelist.qml: add the setCurrentDiveListIndex() helper
Add the setCurrentDiveListIndex() wrapper for: diveListView.currentIndex = idx wich also makes it possible to disable the scroll animation when selecting dive list indexes which are too far apart. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
fbbb6ba4fb
commit
d3607e0b77
1 changed files with 12 additions and 0 deletions
|
@ -364,4 +364,16 @@ Kirigami.ScrollablePage {
|
||||||
event.accepted = true
|
event.accepted = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setCurrentDiveListIndex(idx, noScroll) {
|
||||||
|
diveListView.currentIndex = idx
|
||||||
|
// updating the index of the ListView triggers a non-linear scroll
|
||||||
|
// animation that can be very slow. the fix is to stop this animation
|
||||||
|
// by setting contentY to itself and then using positionViewAtIndex().
|
||||||
|
// the downside is that the view jumps to the index immediately.
|
||||||
|
if (noScroll) {
|
||||||
|
diveListView.contentY = diveListView.contentY
|
||||||
|
diveListView.positionViewAtIndex(idx, ListView.Center)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue