SpringAnimation QML Type
プロパティがバネのような動きで値を追跡できるようにします。詳細...
Import Statement: | import QtQuick |
Inherits: |
プロパティ
詳しい説明
SpringAnimation はスプリングの振動動作を模倣します。適切なspring 定数で加速度を制御し、damping で効果が消えるまでの時間を制御します。
また、アニメーションの最大velocity を制限することもできます。
次のRectangle は、マウスがクリックされると、SpringAnimationを使ってマウスの位置に移動します。x
とy
の値にBehavior が使われているのは、これらの値が変更されるたびにSpringAnimationが適用されることを示しています。
import QtQuick Item { width: 300; height: 300 Rectangle { id: rect width: 50; height: 50 color: "red" Behavior on x { SpringAnimation { spring: 2; damping: 0.2 } } Behavior on y { SpringAnimation { spring: 2; damping: 0.2 } } } MouseArea { anchors.fill: parent onClicked: (mouse)=> { rect.x = mouse.x - rect.width/2 rect.y = mouse.y - rect.height/2 } } }
他のアニメーションタイプと同様に、SpringAnimationはトランジション、ビヘイビア、プロパティ値のソースなど、さまざまな方法で適用できます。Animation and Transitions inQt Quickdocumentationでは、アニメーションを作成するための様々な方法を紹介しています。
SmoothedAnimation,Animation and Transitions inQt Quick,Qt Quick Examples - Animation,Qt Quick Demo - Clocksも参照してください 。
プロパティの説明
damping : real |
このプロパティは、スプリングの減衰値を保持します。
この値は、バネのような動きが静止するまでの時間を表します。デフォルト値は0です。
有効な値の範囲は 0 - 1.0 です。値が小さいほど、静止するのが速くなります。
epsilon : real |
このプロパティはバネのイプシロンを保持します。
イプシロンは、0に等しいとみなされるほど0に近い値の変化率と変化量です。これは値の用途によって異なります。ピクセル位置なら0.25で十分でしょう。スケールの場合は0.005で十分です。
デフォルトは0.01です。この値を調整することで、パフォーマンスが少し向上します。
mass : real |
このプロパティは、移動されるプロパティの「質量」を保持します。
デフォルト値は1.0です。
質量が大きいほど動きは遅くなり、アイテムが静止したときのバネのような動きが大きくなります。
modulus : real |
このプロパティはモジュラスの値を保持します。デフォルト値は 0 です。
modulus を設定すると、ターゲット値はモジュラスで「包み込む」ように強制されます。例えば、モジュラスを 360 に設定すると、370 の値が 10 に折り返されます。
spring : real |
velocity : real |
このプロパティは、ソースをトラッキングする際に許容される最大速度を保持する。
デフォルト値は 0(最大速度なし)です。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.