Hi,
example below should work,
you have indeed to set proper targets,
“on scale” works as a shortcut, and only inside the target, not from a different component.
main.qml
import QtQuick 2.0
Rectangle {
width: 360
height: 360
ZoomAnimation {
id: myZoomAnimation
myTarget: myRect
}
Rectangle {
id: myRect
color: "red"
width: 100
height: 100
anchors.centerIn: parent
MouseArea {
anchors.fill: parent
onClicked: {
myZoomAnimation.running = true;
}
}
}
}
ZoomAnimation.qml
import QtQuick 2.0
SequentialAnimation {
property variant myTarget;
PropertyAnimation {
target: myTarget
property: "scale"
to: 2.0
duration: 500
}
PropertyAnimation {
target: myTarget
property: "scale"
to: 1.0
duration: 500
}
}
↧