Op 6-2-2011 14:45, Vinayakam Murugan schreef:

On Sun, Feb 6, 2011 at 5:40 AM, Thomas Perl <[email protected] <mailto:[email protected]>> wrote:

    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).


What I do is something like this:

//in definition of inner:
opacity: state == "onscreen" || onscreenTransition.running ? 1 : 0

//your transition:
transitions: [
  Transition {
       AnchorAnimation {id:onscreenTransition}
  }
]

I think that achieves what you want in a simpler way, and without having to introduce something like PropertyChangesLater.

HTH,

André

_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml

Reply via email to