Hi, I often have the case where items have two states: One state being "on-screen" and visible, the other state being "off-screen" and not visible. I'd like to animate between those states, so that the user "knows" that the view is going away and coming back. For performance reasons, the "off-screen" state should set "opacity" to 0. Now, if I use PropertyChanges in the state to set the opacity, the "sliding out" animation isn't visible, because the property changes as soon as the state is entered, therefore the animation isn't visible anymore. I'm currently working around this using a SequentialAnimation and ScriptAction in the transition, like this:
transitions: Transition {
SequentialAnimation {
ScriptAction { script: inner.opacity = 1 }
AnchorAnimation {}
ScriptAction { script: inner.opacity = (inner.state=='onscreen') }
}
}
(where "inner" is the object that i move, and it has two states
"onscreen" and "offscreen")
I imagine this is a common use case. How do you handle it currently? I
could imagine something like a "PropertyChangesLater" being useful,
behaving the same way as PropertyChanges, but carrying out the changes
after all transitions have finished. This way, I could just say (in
the "offscreen" state):
PropertyChangesLater {
target: inner
opacity: 0
}
Does this make sense? Can this be considered for a future QML version,
or is there an easier, obvious way to accomplish what I'm trying to
do?
Attached are two files: state.qml (my current workaround) and
state-proposed.qml (example of how the same feature would be
implemented using PropertyChangesLater).
Thanks,
Thomas
state.qml
Description: Binary data
state-proposed.qml
Description: Binary data
_______________________________________________ Qt-qml mailing list [email protected] http://lists.qt.nokia.com/mailman/listinfo/qt-qml
