aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/qml/propertyanimation.qml
blob: 8850e72d240480f59049f13184c8300ffadf03bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (C) 2017 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick

Row {

//![transition]
Rectangle {
    id: rect
    width: 100; height: 100
    color: "red"

    //! [single state]
    states: State {
        name: "moved"
        PropertyChanges { target: rect; x: 50 }
    }
    //! [single state]

    transitions: Transition {
        PropertyAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
    }
}
//![transition]

//![behavior]
Rectangle {
    width: 100; height: 100
    color: "red"

    Behavior on x { PropertyAnimation {} }

    MouseArea { anchors.fill: parent; onClicked: parent.x = 50 }
}
//![behavior]

//![propertyvaluesource]
Rectangle {
    width: 100; height: 100
    color: "red"

    SequentialAnimation on x {
        loops: Animation.Infinite
        PropertyAnimation { to: 50 }
        PropertyAnimation { to: 0 }
    }
}
//![propertyvaluesource]

    //![standalone]
    Rectangle {
        id: theRect
        width: 100; height: 100
        color: "red"

        // this is a standalone animation, it's not running by default
        PropertyAnimation { id: animation;
                            target: theRect;
                            property: "width";
                            to: 30;
                            duration: 500 }

        MouseArea { anchors.fill: parent; onClicked: animation.running = true }
    }
    //![standalone]
}