Last active
December 27, 2015 20:49
-
-
Save carambula/7387438 to your computer and use it in GitHub Desktop.
Example of Framer JS's convertPoint utility in use.
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
//DEMO: drag the childView inside the box and click the view outside to send it to the relative location of the inner one. | |
// set up three views, one to hold a child and two that match except for their superViews | |
parentView = new View({x: 100, y:100, width: 300, height: 300}) | |
childView = new View({x: 20, y: 20, width: 60, height: 40, superView: parentView}) | |
cousinView = new View(childView) | |
cousinView.superView = parentView.superView | |
childView.dragger = new ui.Draggable(childView) | |
cousinView.on("click", function(){ | |
convertedFrame = utils.convertPoint(childView.frame, childView, cousinView.superView) | |
cousinView.animate({ | |
properties: {x: convertedFrame.x, y: convertedFrame.y}, | |
curve: "ease-in-out", | |
time: 350 | |
}).on("end", function(){ | |
cousinView.animate({ | |
properties: {x: 20, y: 20}, | |
curve: "spring(30,10,800)" | |
}) | |
}) | |
}) |
It's once removed—not under the same parent :D
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CousinView is genius. I think others call it a SiblingView :-)