-
-
Notifications
You must be signed in to change notification settings - Fork 530
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
feat(iOS)!: change default animation curve & duration #2477
Merged
kkafar
merged 19 commits into
main
from
@kkafar/native-native-animtions-for-ios-native-native
Nov 6, 2024
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
4e1c12d
Use 0.5 for default transition duration value __but__ keep old animat…
kkafar cc641c6
Write Push transition using property animator and spring timing curve
kkafar 845ab1c
Linter
kkafar d5d5809
Write Pop transition using property animator and spring timing curve
kkafar 24fc134
Implement non-interactive simple push using UIViewPropertyAnimator [PRB]
kkafar ebe507e
Implement interactive simple-push using UIViewPropertyAnimator
kkafar aeec238
Make RNSScreenStackAnimator a source of truth on animation properties…
kkafar 12b747d
Update documentation: default transition lasts 500ms
kkafar 9bde620
Update default transition duration in Android spec
kkafar 0e1f818
Implement both interactive and not slide_from_left using UIViewProper…
kkafar 81fe5ed
Move comment on default spring animation to helper function
kkafar 23300c6
stash changes for another animation
kkafar 0e13917
Merge branch 'main' into @kkafar/native-native-animtions-for-ios-nati…
kkafar 82d3629
Set damping ratio to 4.56
kkafar bbad9e3
Restore slide_from_bottom to old behaviour
kkafar a772a33
Fix typos
kkafar 7b0bdca
Review fixes
kkafar 7a2dfc9
Add fix for missing header animation
kkafar a8e13c3
Update comment for inFlightAnimator
kkafar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#import <UIKit/UIKit.h> | ||
#import "RNSScreenStackAnimator.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface RNSPercentDrivenInteractiveTransition : UIPercentDrivenInteractiveTransition | ||
|
||
@property (nonatomic, nullable) RNSScreenStackAnimator *animationController; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#import "RNSPercentDrivenInteractiveTransition.h" | ||
|
||
@implementation RNSPercentDrivenInteractiveTransition { | ||
RNSScreenStackAnimator *_animationController; | ||
} | ||
|
||
#pragma mark - UIViewControllerInteractiveTransitioning | ||
|
||
- (void)startInteractiveTransition:(id<UIViewControllerContextTransitioning>)transitionContext | ||
{ | ||
[super startInteractiveTransition:transitionContext]; | ||
} | ||
|
||
#pragma mark - UIPercentDrivenInteractiveTransition | ||
|
||
// `updateInteractiveTransition`, `finishInteractiveTransition`, | ||
// `cancelInteractiveTransition` are forwared by superclass to | ||
// corresponding methods in transition context. In case | ||
// of "classical CA driven animations", such as UIView animation blocks | ||
// or direct utilization of CoreAnimation API, context drives the animation, | ||
// however in case of UIViewPropertyAnimator it does not. We need | ||
// to drive animation manually and this is exactly what happens below. | ||
|
||
- (void)updateInteractiveTransition:(CGFloat)percentComplete | ||
{ | ||
if (_animationController != nil) { | ||
[_animationController.inFlightAnimator setFractionComplete:percentComplete]; | ||
} | ||
[super updateInteractiveTransition:percentComplete]; | ||
} | ||
|
||
- (void)finishInteractiveTransition | ||
{ | ||
[self finalizeInteractiveTransitionWithAnimationWasCancelled:NO]; | ||
[super finishInteractiveTransition]; | ||
} | ||
|
||
- (void)cancelInteractiveTransition | ||
{ | ||
[self finalizeInteractiveTransitionWithAnimationWasCancelled:YES]; | ||
[super cancelInteractiveTransition]; | ||
} | ||
|
||
#pragma mark - Helpers | ||
|
||
- (void)finalizeInteractiveTransitionWithAnimationWasCancelled:(BOOL)cancelled | ||
{ | ||
if (_animationController == nil) { | ||
return; | ||
} | ||
|
||
UIViewPropertyAnimator *_Nullable animator = _animationController.inFlightAnimator; | ||
if (animator == nil) { | ||
return; | ||
} | ||
|
||
BOOL shouldReverseAnimation = cancelled; | ||
|
||
id<UITimingCurveProvider> timingParams = [_animationController timingParamsForAnimationCompletion]; | ||
|
||
[animator pauseAnimation]; | ||
[animator setReversed:shouldReverseAnimation]; | ||
[animator continueAnimationWithTimingParameters:timingParams durationFactor:(1 - animator.fractionComplete)]; | ||
|
||
// System retains it & we don't need it anymore. | ||
_animationController = nil; | ||
} | ||
|
||
@end |
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Not sure why header looks so bad in those transitions, I think this line should control the state of animation of header too. Are those values not changing pretty linearly ?
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.
Header looks bad only in non-interactive transitions. TBH I'm surprised that it does not look bad in old implementation - the docs suggest that it should look bad
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 do not know what code drives the header transition in non-interactive transitions (notice that I'm not swiping on these recordings). Need to spend some time on this.
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.
The docs mention the native header transition where the back button title travels to the place of title when navigating back/forward. It works only with the default animations. For
simple_push
it was the fade animation in header iirc.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 guess you're right. I've just confirmed that it has not been a fluke - on main there is nice fade transition. Do you happen to remember where this is animated? Or is this handled entirely by UIKit?
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.
Figured this out in: 7a2dfc9