material-motion / motion-animator-objc Goto Github PK
View Code? Open in Web Editor NEWA Motion Animator creates performant, interruptible iOS animations from motion specs.
License: Apache License 2.0
A Motion Animator creates performant, interruptible iOS animations from motion specs.
License: Apache License 2.0
As confirmed by #60.
It's often desirable to trace animations for a specific animation scope.
http_archive
instead of git_repository
v1.3.0 of the interchange introduced a new API for capturing velocity in a motion spec: https://github.com/material-motion/motion-interchange-objc/releases/tag/v1.3.0
We should support this property and implement it in the motion animator.
I don't think swift_wrapper is supported in Xcode 7.
This would be similar to UIView's animate APIs:
MotionAnimator.animate(withTiming: timing) {
}
The implementation would simply create a throw-away motion animator instance and call through to the instance APIs.
Adding support for explicit animations is trivial because we can do a one-to-one mapping of animations to completion handlers.
Adding support for implicit animations, however, is non-trivial because multiple animations map to the same completion handler. We'll have to implement the animation delegate on each added animation and coalesce the overall completion state into a single invocation of the completion handler.
This would bring our API closer in alignment to UIView's animation APIs.
When making additive animations we always want to be animating from the latest model value, not the latest presentation layer value.
When we're not making additive animations, we do want to go from the current presentation layer value.
[CATransaction begin];
[CATransaction setCompletionBlock:^{
NSLog(@"Did complete");
}];
[_animator animateWithTiming:timing ...];
[CATransaction commit];
If timing.duration == 0
then the transaction's completion block should still be invoked.
Consider the following spec:
struct MotionSpec spec = {
.expand = {
.verticalMovement = {
.delay = 0.000, .duration = 0.350, .curve = EaseInEaseOut,
},
.scaling = {
.delay = 0.000, .duration = 0.350, .curve = EaseInEaseOut,
},
},
.collapse = {
.verticalMovement = {
.delay = 0.000, .duration = 0.350, .curve = EaseInEaseOut,
},
.scaling = {
.delay = 0.000, .duration = 0.350, .curve = EaseInEaseOut,
},
},
};
All of the animations are described in relation to a relative timeline. If the timing could correspondingly be described in a relative fashion, our struct might look like this:
struct MotionSpec spec = {
.expand = {
.verticalMovement = {
.delay = 0.0, .duration = 1.0, .curve = EaseInEaseOut,
},
.scaling = {
.delay = 0.0, .duration = 1.0, .curve = EaseInEaseOut,
},
},
.collapse = {
.verticalMovement = {
.delay = 0.0, .duration = 1.0, .curve = EaseInEaseOut,
},
.scaling = {
.delay = 0.0, .duration = 1.0, .curve = EaseInEaseOut,
},
},
};
animator.relativeTimingDuration = 0.350;
All animation timing would correspondingly be multiplied by the relativeTimingDuration.
The need for this comes from wanting to be able to inherit UIView animations in headless sublayers.
Values passed to the animator are currently absolute. It would be nice to also be able to provide relative values.
// Move a view 50 points down.
[animator animateWithTiming:timing
toLayer:view.layer
withRelativeValues:@[ @0, @50 ]
keyPath:MDMKeyPathY];
This feature should take care when implementing support for shouldReverseValues.
We may find it beneficial to to implement CAAction
so that our animations get routed through the expected action architecture. The challenge is that we need to be able to provide the timing struct to the action implementation and that action implementation needs to be able to create an animation object using the animator's configurations. This may require splitting the animator's animation creation logic out to some standalone method.
Some references:
In the method, ActionForKey(CALayer *layer, SEL _cmd, NSString *event)
, the returned NSNull
value was causing crashes because it does not respond to selectors (like runAction:forKey:
). This is easily reproduced when running the unit test suite on iOS 8.2 or lower simulators. The contract for actionForKey:
should return nil
if no action was found, which is what we want in this case.
This will improve auto completion when calling the API.
We want to show that the MotionAnimator can be used to animate both UIView-associated layers and headless layers in the same manner.
How might we represent timing for multiple keyframes?
Calling either of these two methods with a nil
completion block will crash.
[animator animateWithTiming:timing
animations:animations
completion:nil];
[animator animateWithTiming:timing
toLayer:aLayer
withValues:values
keyPath:keyPath
completion:nil];
Size and point animations are always being made additive, regardless of the value of wantsAdditive
.
We currently augment the duration/delay of the animation, but setting the timeScaleFactor to the animation's speed should give us better control over the speed of spring animations as well.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.