-
Notifications
You must be signed in to change notification settings - Fork 476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Animation Path Support #151
Conversation
…tion for .animate). Added some basic examples under app.coffee in CactusFramer. Added a few useful functions to Utils.
…issue with animation paths and nested elements.
… functions as any argument value, which will be evaluated when the path node actually gets created.
…f the layer. Changed print -> toString.
A video of your examples would be nice to see what the expected speed is. Hard to tell if the speed is correct or not. |
@jordandobson The speed is as always determined by your curve (animation curve, not path) settings. So if you specify |
@tisho - It seemed fine then. Some seemed slow but I didn't notice any stuttering on the few devices I tested on. I'll dig into this more later but I love this idea... I used path animations a lot back in the flash days and somewhat miss it.I've also had to deal with flower style animations lately and this approach would make it sooo much easier. Nice work! |
This is awesome! No comments about the API, but I'm really excited for the functionality. |
@tisho , I haven't tried it out, but I can't wait to say you're awesome! |
👍 looks amazing. |
This looks super useful 👍 |
I'll start merging this as soon as I finished custom scrolling. |
Any chance that this implementation will allow a user to control the speed of motion. So the user could - for example - slide a circular slider to 50% ? |
Wanted to bring this back up. Tisho, I think in general this is 💯👌. I think SVG is definitely the way to go, given it's broad support. I think Path should take a string, that way we can either use Sketch plugins (https://github.com/joshpuckett/FramerModules/blob/master/SVGLayer/pathToSVG.sketchplugin), or better yet build that in to the importer. Proposal: name sketch layers "paths.pathName" (where "path." is protected). Once you import, you can access all your path layers in the paths object, and load them in the API you've proposed:
Would be nice to merge this in, leave it undocumented for a while so we can test... |
Thanks for resurrecting this @joshpuckett. I'll start fixing up the merge conflicts. Path does take a string ( 👍 wrt importing paths from Sketch. Should there be some sort of naming convention for paths you actually want to use for animation? Otherwise we'd be importing all kinds of tiny detail paths that would have otherwise gotten flattened at import. Thoughts? |
Yea sorry, for naming convention you'd have to name your layer something like
Default paths are named "Path 1" in Sketch, so we'd just add paths to the imported paths object that started with "paths.", make sense? |
Update. We're still looking to land this. |
I've got a lighter week ahead of me. Should be able to finish it up. |
What are the biggest todo's? Maybe I can help? Also make sure you re-merge master. We did a ton of cleanup. |
Merging with master is one of them, and I've already started on that. Also, tests and all of the stuff that I've put under "Open Questions". |
@tisho You're a legend. Can't wait for this to land. |
…Fixed an issue with debug method which would incorrectly render anchor points with a zero coordinate. Added PathAnimation studio project to use in testing.
…e compatible with the new animateTo syntax. Cleaned up debug code.
…ring, instead of a Path instance. Fixed an issue that prevented debug markers from drawing if they were equal to 0.
@nvh Can you take another look at this PR? I made some changes:
|
I am looking forward to use this! |
framer/Animation.coffee
Outdated
@@ -164,6 +216,14 @@ class exports.Animation extends BaseClass | |||
@emit("stop") if emit | |||
Framer.Loop.off("update", @_update) | |||
|
|||
if @_debugLayer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would check on @options.debug
instead of @_debugLayer
here
It looks great now, but as the animation API changes are still a bit in flux, so I'm still hesitant to merge this in before that one is merged, to avoid merge conflicts later on.
@koenbok what do you think? |
…e of path in options vs truthiness.
…ntext and createSVGElement)
…bug element code.
Thanks for the comments again @nvh. I've updated the PR with the following:
Now, re: making
Re: As for when this should be merged, I agree that it can probably wait until the new animation API is done, but that's your call. |
Thanks for the quick response, @tisho! I agree with your argumentation for keeping It's good to merge now, so will do so as soon as the animation API is merged, which shouldn't take long. FYI: We changed our minds about |
We're going to wait a little bit until the new animation api completely settles and circle back. Should be a matter of a few weeks. |
What's the current status of this? |
I could really use some animation paths right now. 😘 |
DO NOT MERGE. FOR DISCUSSION ONLY.
Hey folks, I've been working on adding support for animation paths to Framer and wanted your help with the design of the API, testing and overall comments.
I prepared a build that's up to date with this PR that you can use to check out the stuff I've been working on. You can download it from here.
Demos
Here are a few demos using that build to get you started:
API Overview
The current implementation is based on SVG. SVG paths (http://www.w3.org/TR/SVG/paths.html) are super versatile, supported by most major browsers and generally a pleasure to work with. I'd like to hear your opinion on this particular choice, though. It informed a lot of the API, as you'll see.
I've added a
path
option to the.animate()
method. You use it like this:There are a number of different ways to create a
Path
object.moveTo, lineTo, hlineTo, vlineTo, curve, curveTo, qcurveTo, smoothCurveTo, qsmoothCurveTo, arc
:The above will create a new cubic bezier curve from 0,0 to 400,400 with control points at 200,200 and 300,300. All path methods return the path object, so you can chain them easily:
Notice that none of the paths specify an origin point. This is because the origin of a path is assumed to be the layer's origin point at the start of the animation.
The
curviness
parameter specifies how "curvy" the path will be as it passes through the points you've specified. A value of 0 will cause the path to be made up of straight lines between the points. A value of 10 will make a pretty curvy line. The default is 5.Refer to the SVG spec for the syntax: http://www.w3.org/TR/SVG/paths.html. It's very terse and extremely powerful, but without visual aids it's kind of a pain to work with quickly.
In this case, the file will be loaded synchronously, the first path from it will be extracted and then used as an animation path. Came in handy when I wanted to draw more complex paths in Sketch and then just loaded them for the animation.
Implementation Details
Here's what happens when you hand an animation path to animation:
true
, a debug layer with a copy of the SVG path and extra elements like control points is created and shown.x
andy
properties of the animation (if they were there) are ignored, because we'll be using the path to inform position. The same goes forrotationZ
ifautoRotate
istrue
(it is by default).getPointAtLength
implementation for SVG paths is used to get the x/y coordinates of the layer at a specific point along the progress of the animation.tick
until the animation ends.Open Questions
Known Issues
Let me know what you think.
In the meantime, I'm going to use a lot of this code to build support for using splines as animation curves (so more than just cubic beziers), which will give us very fine-grained animation control.