feat: expose `animating` property

to find out whether the pages in the stack are currently being animated
This commit is contained in:
Lukáš Tinkl 2023-09-27 12:55:52 +02:00 committed by Lukáš Tinkl
parent f3a5a61771
commit b8eccc67a2
2 changed files with 12 additions and 3 deletions

View File

@ -11,6 +11,7 @@ StackLayout {
readonly property var previousItem: items[previousIndex]
readonly property var currentItem: items[currentIndex]
readonly property bool animating: !!d.crossFaderAnim && d.crossFaderAnim.running
clip: true
@ -22,6 +23,11 @@ StackLayout {
}
}
QtObject {
id: d
property var crossFaderAnim
}
Component {
id: crossFader
@ -68,13 +74,15 @@ StackLayout {
if (previousItem && currentItem && (previousItem != currentItem)) {
previousItem.visible = true;
currentItem.visible = true;
var crossFaderAnim = crossFader.createObject(parent,
if (!!d.crossFaderAnim)
d.crossFaderAnim.destroy()
d.crossFaderAnim = crossFader.createObject(parent,
{
fadeOutTarget: previousItem,
fadeInTarget: currentItem
});
crossFaderAnim.restart();
d.crossFaderAnim.restart();
}
previousIndex = currentIndex;
}
}
}

View File

@ -18,6 +18,7 @@ StatusModal {
readonly property int itemsCount: stackLayout.count
readonly property var currentItem: stackLayout.currentItem
readonly property alias animating: stackLayout.animating
property Item backButton: StatusBackButton {
visible: replaceItem || stackLayout.currentIndex > 0