2012-12-12 5 views
3

나는 전환 애니메이션을 만들었습니다. 그래서 상태가 변경되면 전환이 발생합니다. 여기에 내가 만든 연속 애니메이션이 있습니다.QML : SequencialAnimation의 실행 속성이 false로 설정되었지만 여전히 실행 중임

SequentialAnimation{ 
      PropertyAnimation{ 
       properties: "width" 
       duration: 300 
      } 
      PropertyAnimation{ 
       properties: "x" 
       duration: 500 
      } 
      Component.onCompleted: { 
       var idx = Math.ceil(Math.random()*2); 
       if(idx===0){ 
        anim0.running = true 
        anim1.running = false 
       } 
       else { 
        anim1.running = true 
        anim0.running = false 
       } 
       console.log("haha"); 
      } 
     } 

     SequentialAnimation{ 
      id: anim0 
      running: false 
      NumberAnimation{ 
       running: anim0.running 
       properties: "x" 
       to: 300 
       duration: 500 
      } 
      Component.onCompleted: console.log("anim0"); 
     } 
     SequentialAnimation{ 
      id: anim1 
      running: false 
      NumberAnimation{ 
       running: anim1.running 
       properties: "x" 
       to: -300 
       duration: 500 
      } 
      Component.onCompleted: console.log("anim1"); 
     } 

먼저 Component.onCompleted 신호에서 JavaScript를 무시하십시오. ID와 SequencialAnimation : anim1 및 anim0 애니메이션의 시작을 방지하지 않습니다, 난 이미 거짓으로 속성을 실행으로 설정 했더라도 거짓으로 Animation 항목의 running 속성을 설정 ...

답변

1

을 계속 실행. 현재 실행중인 경우 중지됩니다.

전환에서 애니메이션을 시작하지 않으려면 전환 안에 넣지 마십시오. 사용자 정의 Animation 항목을 항상 Transition 외부에 정의하고 animationId.start() 기능을 사용하여 원하는 경우 트리거 할 수 있습니다.

자세한 내용은 documentation page을 참조하십시오.

+0

안녕하세요 .. 도움을 요청합니다 ..하지만 어떻게해야합니까? sequentialAnimation에서 호출해야합니까? 또는 신호? 나는 qml에 대해 매우 새로운 것입니다. –

+0

글쎄, 이것은 당신이 원하는 것에 달려 있습니다 ... 어떤 경우에'running' 속성을 true로 설정 했습니까? –

+0

ScriptAction을 사용하여 animationId.start()를 호출하면 작동합니다 .. thx bro .. –

관련 문제