Last active
August 29, 2015 14:03
-
-
Save AdrianRossouw/f8dfac7035c882022666 to your computer and use it in GitHub Desktop.
famous snap
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
// import dependencies | |
var Engine = require("famous/core/Engine"); | |
var Surface = require("famous/core/Surface"); | |
var Modifier = require("famous/core/Modifier"); | |
var Transform = require("famous/core/Transform"); | |
var Transitionable = require("famous/transitions/Transitionable"); | |
var SnapTransition = require("famous/transitions/SnapTransition"); | |
// create the main context | |
var mainContext = Engine.createContext(); | |
var surface = new Surface({ | |
size:[100,100], | |
content: 'Click Me', | |
classes: ['red-bg'], | |
properties: { | |
textAlign: 'center', | |
lineHeight: '100px' | |
} | |
}); | |
var modifier = new Modifier({ | |
origin: [.5,.5], | |
transform: Transform.translate(0,0,0) | |
}); | |
var mod2 = new Modifier({ | |
transform: Transform.rotateX(0.2) | |
}); | |
Transitionable.registerMethod('snap', SnapTransition); | |
var transition = { | |
method: "snap", | |
period: 1000, | |
dampingRatio: .3, | |
velocity: 0 | |
}; | |
surface.on("click", function(){ | |
modifier.setTransform(Transform.translate(250,0,0),transition); | |
}); | |
mainContext.add(modifier).add(mod2).add(surface); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment