Last active
December 27, 2015 20:49
-
-
Save carambula/7387609 to your computer and use it in GitHub Desktop.
Framer demo based on Craig Murray's question in the Framer JS Facebook group: https://www.facebook.com/groups/framerjs/permalink/416670385126705/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var picRef = new ImageView({ | |
x:100, | |
y:100, | |
width:400, | |
height:300, | |
image: "http://distilleryimage7.ak.instagram.com/310adf44426011e38fa722000a9f1885_8.jpg" | |
}); | |
var turnLeft_BTN = new View({ | |
x:4, | |
y:4, | |
width:50, | |
height:50, | |
}); | |
// setup button event for rotate left | |
cycler = utils.cycle(-90, -180, -270, 0); | |
turnLeft_BTN.style.cursor = "pointer"; | |
turnLeft_BTN.on("click", function() { | |
// get the next position value to rotate to | |
var nextRotate = cycler(); | |
picRef.animateStop() | |
picRef.rotationZ = picRef.rotationZ <= -270 ? 360 + picRef.rotationZ : picRef.rotationZ | |
picRef.animate({ | |
properties: {rotationZ:nextRotate}, | |
curve: "spring(220,20,1600)", | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment