2013-04-14 76 views
1

有窗戶,其佈局由states and transition設計。我們知道當狀態改變時,transition-animation會自動啓動,但當轉換動畫沒有完成時,我改變狀態,這會造成麻煩。就像slow in reacting;如何解決它?謝謝...如何停止QML中的過渡動畫?

它是這樣的:

Flickable {

  id: content 
      anchors.fill: parent 
      flickableDirection: Flickable.HorizontalFlick 
      contentWidth: width * 2 
      contentHeight: height 
      clip: true 

      onFlickStarted: { 
       if(horizontalVelocity > 0) { 
        regAndFind.state = "Find" 
       } 
       else { 
        regAndFind.state = "Register" 
       } 
      } ....... 
} 
states: [ 
    State { 
     name: "Register" 
     PropertyChanges { 
      target: slider 
      x: 0 
     } 
     PropertyChanges { 
      target: content 
      contentX: 0 
     } 
    }, 
    State { 
     name: "Find" 
     PropertyChanges { 
      target: slider 
      x: parent.width/2 
     } 
     PropertyChanges { 
      target: content 
      contentX: parent.width 
     } 
    } 
] 

transitions: [ 
    Transition { 
     NumberAnimation { 
      target: slider 
      property: "x" 
      duration: 600 
     } 
     NumberAnimation { 
      target: content 
      property: "contentX" 
      duration: 600 
     } 
    } 
] 

回答

1

閱讀有關的設爲Qml animation element

之前轉移到其他國家,你可以調用Animation::stop()功能停止動畫之間。請注意,它會立即停止動畫,並且動畫將不會對屬性值產生進一步的影響。