Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@valorcurse
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save valorcurse/f688baf5e6dcfd714e69 to your computer and use it in GitHub Desktop.
Save valorcurse/f688baf5e6dcfd714e69 to your computer and use it in GitHub Desktop.
Testing rotation animations
import QtQuick 2.2
import QtQuick.Window 2.1
Window {
visible: true
width: 360
height: 360
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: {
rect.state = rect.state === "clicked" ? "" : "clicked";
}
}
Rectangle {
id: rect
width: 50
height: 50
color: "blue"
anchors.centerIn: parent
function getRandom() {
var rand = Math.floor(Math.random() * 360) + 1;
console.log("Random: " + rand);
return rand;
}
states: [
State {
name: "clicked"
PropertyChanges {
target: rect
rotation: getRandom()
}
}
]
transitions: Transition {
to: "clicked"
// PropertyAnimation {
// target: rect
// properties: "rotation"
// duration: 500
// }
RotationAnimation {
target: rect
duration: 500
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment