Skip to content

Commit

Permalink
fix(ios): animation state of some scenes might be out of sync
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwcg committed Feb 28, 2024
1 parent 0a0d88d commit f4abb9b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions ios/sdk/module/animation2/HippyNextAnimationModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,17 @@ - (void)connectAnimationToView:(UIView *)view {
NSNumber *animationId = p.animationIdWithPropDictionary[prop];
HippyNextAnimation *anim = self.animationById[animationId];
if (HippyNextAnimationReadyState != anim.state) {
return;
continue;
}

// TODO: use contains rotateY to judge
if ([HippyNextAnimation isShadowViewAnimationProp:prop treatTransformAsShadowAnimation:YES]) {
// connect to ShadowView object
__weak __typeof(self)weakSelf = self;
[self.bridge.uiManager executeBlockOnUIManagerQueue:^{
if (HippyNextAnimationStartedState == anim.state) {
return;
}
__strong __typeof(weakSelf)strongSelf = weakSelf;
HippyShadowView *shadowView = [strongSelf.bridge.uiManager shadowViewForHippyTag:hippyTag];
if (!shadowView) return;
Expand All @@ -282,7 +285,7 @@ - (void)connectAnimationToView:(UIView *)view {
} else {
// connect to UIView object
if (![anim prepareForTarget:view withType:prop]) {
return;
continue;
}
[anim startAnimation];
anim.state = HippyNextAnimationStartedState;
Expand Down Expand Up @@ -327,14 +330,14 @@ - (void)requestUpdateUILayout:(HippyNextAnimation *)anim withNextFrameProp:(NSDi
// merge all nextFrameProps
HippyShadowView *shadowView = anim.targetObject;
NSMutableDictionary *mutableProps = _updatedPropsForNextFrameDict[shadowView.hippyTag].mutableCopy;
NSString *propKey = nextFrameProp.allKeys.firstObject;

if (!mutableProps) {
// first set, add original props if has
id originalPropObj = shadowView.props[propKey];
if (originalPropObj) {
mutableProps = [NSMutableDictionary dictionaryWithObject:originalPropObj forKey:propKey];
}
// Note that we do not need to get the original props from `shadowView.props`,
// because the raw data might also be animated, it may be outdated,
// but at the same time, doing so limits some possible scenarios,
// such as the original props value is an array, and the effects are not superimposed.
// Because Transform Animations are superimposed, they are not affected by this restriction.
mutableProps = [NSMutableDictionary dictionary];
}

// then we merge original props with the new nextFrameProp
Expand Down

0 comments on commit f4abb9b

Please sign in to comment.