2017-06-08 4 views
1

複雑なQMLコンポーネントでアニメーションを一時的に無効にする(無視する/表示しない)ことは可能ですか?その後、アニメーションをアクティブにして、いつものように動作します。複雑なQMLコンポーネントのアニメーションを一時的に無効にする(無視する/表示しない)

たとえば、 QMLの複雑なページにはオブジェクトのデータが表示されますが、小さなアニメーションがたくさんあります。データオブジェクトを変更する場合、これらのアニメーションは無視する必要があります。

Rectangle { 
    anchors.fill: parent 
     property variant cppViewModel: MyCppViewModel { 
      onBeforDataObjectChanged: { 

      } 
      onAfterDataObjectChanged: { 

      } 
     } 

    Rectangle { 
     id: idRect1 
     Behavior on x { NumberAnimation { ... }} 
     Behavior on y { NumberAnimation { ... }} 
     x: cppViewModel.dataObject.offsetX 
     y: cppViewModel.dataObject.offsetY 
     scale: cppViewModel.dataObject.scale 

     Rectangle { 
      id: idRect2 

      width: cppViewModel.dataObject.width 
      heigth: cppViewModel.dataObject.heigth 
      Behavior on width { NumberAnimation { ... }} 
      Behavior on heigth { NumberAnimation { ... }} 

      ColumnLayout { 
       Rectangle { 
        Layout.preferredHeight: 100 * cppViewModel.dataObject.width1 
        Behavior on Layout.preferredHeight { NumberAnimation { duration: 500; easing.type: Easing.OutQuad; }} 
        //... Any number of children with animation 
       } 
      } 
     } 
    } 

    PropertyAnimation { target: idRect1; property: "scale"; from: 0.9; to: 1.0; ... } 
} 

現在のデータオブジェクトのプロパティの値が変更された場合は、アニメーションが必要です。オブジェクト全体が別のオブジェクトに変更された場合、アニメーションをブロックする必要があります。

+0

こんにちは、私の想像力を助けるために、広告コードをお願いしますか?しかし、私は答えが**はい** – derM

+0

になると思う。実際のコードでは2000以上の行。 –

+0

それはそれらの '行動'についてですか? – derM

答えて

1

Animationを無効にするにはさまざまな方法がありますが、正しい方法はAnimationの起動方法によって異なります。

Animationrunning-propertyを設定することにより開始された場合、あなたは単にanimationsEnabledあなたはどこか別の場所に定義し、それに応じて切り替えることが持っている性質である条件に&& animationsEnabled を追加することができます。

Animationを開始するために関数:run()を使用する場合、解はになりません。です。あなたはBehavior whithin Animationを使用する場合は

あなたはBehaviorとそのAnimationを無効にBehaviors enabled-propertyを使用することができます。

最後に、私はTransitionを考えることができます。 BehaviorTransition has a enabled -propertyのように、非アクティブにします。

私はアニメーション化する方法を忘れていないと思いますが、あなたの問題に適した解決策が見つかるはずです。

関連する問題