How do I detect the end of NumberAnimation inside transition?



  • How can I detect the end of NumberAnimation inside transition?

    Here is my code:

    @
    transitions:[
    Transition {
    ...
    },

        Transition {
            from: "*"
            to: "PASSIVE"
    
            ParallelAnimation{
                NumberAnimation{
                    id: moveAnim 
                    properties:"x,y"
                    duration:1000
                    easing.type: "InOutElastic"
                    onRunningChanged: {
                          if(!moveAnim.running){
                                 console.log("End of transition!");
                                // send signal, call js function, etc.
                          }
                    } 
                }
    
    
            }
        }
    ]
    

    @

    This method with catching onRunningChanged and checking the state of running property works perfectly if NumberAnimation is placed inside Behavior, but doesn't seem to work inside transition. What am I doing wrong?



  • Hello,

    you can put your NumberAnimation in SequentialAnimation and use "ScriptAction":http://doc.qt.nokia.com/4.7-snapshot/qml-scriptaction.html This way ScriptEction will be executed after NumberAnimation finishes.



  • Animations also have an running property, right? So, you can use onRunningChanged to respond to changes in the run state of an animation.



  • Andre, the problem is that onRunningChanged does not work if Animation is inside transition. It works if Animation is inside Behavior, but that's not what I need.

    task_struct, thank you. I already found a quick temporary solution by defining bool property, changing it in PropertyAction put in SequentialAnimation after the NumberAnimation and then catching On<property>Changed event like this:

    @
    property bool trigger: false
    onTriggerChanged: triggerChangeProc()
    ...
    Transition {
    from: "*"
    to: "PASSIVE"
    SequentialAnimation{

                NumberAnimation{
                    properties:"x,y"
                    duration:1000
                    easing.type: "InOutElastic"
    
                }
                PropertyAction{
                    target:systemMessageRect; property:"trigger"; value: "true"
                }
    
            }
    
    
        }
    

    function triggerChangeProc(){
    //do the stuff
    }

    @

    Edit: but your suggestion seems to be much better.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.