Skip to content
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

Add ability for Animated views to be created with scale X or scale Y #18181

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
673c999
Initial changes to add layout animation
Liamandrew Mar 3, 2018
cb0667c
Initial changes to add layout animation
Liamandrew Mar 3, 2018
2b633a2
Merge branch 'pr/scaleAnimations' of https://github.com/Liamandrew/re…
Liamandrew Mar 3, 2018
8ae3395
Adjust scale parameters correctly
Liamandrew Mar 3, 2018
498cf7e
Reënable iOS and tvOS tests
hramos Mar 5, 2018
a1295e1
Fix Viewpager on Android when using native navigation.
ruiaraujo Mar 5, 2018
f389ad8
Move fb_xplat_cxx.bzl to xplat/build_defs
Mar 5, 2018
8769057
Remove log in JSDevSupportModule
mdvacca Mar 5, 2018
3f8a04b
Revert "Better Android Gradle Plugin 3.x integration"
janicduplessis Mar 5, 2018
9f239d7
Use react.gradle from repo root instead of copy in RNTester
janicduplessis Mar 5, 2018
4466b6f
Refactor BridgeListener into JSIModulesProvider
mdvacca Mar 5, 2018
19b9851
Update VirtualizedList to not throw with double constructor
sophiebits Mar 5, 2018
860fcd4
Update node-notifier (has mem leak fix)
rickhanlonii Mar 5, 2018
19a4a7d
Remove callFunctionSync experimental APIs
Mar 5, 2018
9366ce4
Update opacity when `disabled` prop is changed
maxkomarychev Mar 5, 2018
b4ce427
iOS: branch out Fabric handling into a separate RCTSurface-compatible…
fkgozali Mar 6, 2018
b98bf1e
Remove polymorphic types from StyleSheetTypes
elicwhite Mar 6, 2018
b6c7e55
Using ReadOnly and Exact types for StyleSheet
elicwhite Mar 6, 2018
52c7957
Fix lint in StyleSheet.compose
sahrens Mar 6, 2018
ac929ef
Fix subtle bugs in cloning and FabricUIManager
mdvacca Mar 6, 2018
e839c91
Generalize JavaOnlyMap's getMap
ayc1 Mar 6, 2018
9d6c798
Initial changes to add layout animation
Liamandrew Mar 3, 2018
23cbb21
Merge branch 'pr/scaleAnimations' of https://github.com/Liamandrew/re…
Liamandrew Mar 6, 2018
460ef0f
remove dependency
Liamandrew Mar 6, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Libraries/LayoutAnimation/LayoutAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ const Types = keyMirror(TypesEnum);

const PropertiesEnum = {
opacity: true,
scaleX: true,
scaleY: true,
scaleXY: true,
};
const Properties = keyMirror(PropertiesEnum);
Expand Down
14 changes: 13 additions & 1 deletion React/Modules/RCTUIManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,10 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
NSString *property = creatingLayoutAnimation.property;
if ([property isEqualToString:@"scaleXY"]) {
view.layer.transform = CATransform3DMakeScale(0, 0, 0);
} else if ([property isEqualToString:@"scaleX"]) {
view.layer.transform = CATransform3DMakeScale(0, 1, 0);
} else if ([property isEqualToString:@"scaleY"]) {
view.layer.transform = CATransform3DMakeScale(1, 0, 0);
} else if ([property isEqualToString:@"opacity"]) {
view.layer.opacity = 0.0;
} else {
Expand All @@ -603,7 +607,11 @@ - (RCTViewManagerUIBlock)uiBlockWithLayoutUpdateForRootView:(RCTRootShadowView *
}

[creatingLayoutAnimation performAnimations:^{
if ([property isEqualToString:@"scaleXY"]) {
if (
[property isEqualToString:@"scaleX"] ||
[property isEqualToString:@"scaleY"] ||
[property isEqualToString:@"scaleXY"]
) {
view.layer.transform = finalTransform;
} else if ([property isEqualToString:@"opacity"]) {
view.layer.opacity = finalOpacity;
Expand Down Expand Up @@ -738,6 +746,10 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
[deletingLayoutAnimation performAnimations:^{
if ([property isEqualToString:@"scaleXY"]) {
removedChild.layer.transform = CATransform3DMakeScale(0.001, 0.001, 0.001);
} else if ([property isEqualToString:@"scaleX"]) {
removedChild.layer.transform = CATransform3DMakeScale(0.001, 1, 0.001);
} else if ([property isEqualToString:@"scaleY"]) {
removedChild.layer.transform = CATransform3DMakeScale(1, 0.001, 0.001);
} else if ([property isEqualToString:@"opacity"]) {
removedChild.layer.opacity = 0.0;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
/* package */ enum AnimatedPropertyType {
OPACITY("opacity"),
SCALE_X("scaleX"),
SCALE_Y("scaleY"),
SCALE_XY("scaleXY");

private final String mName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,32 @@ Animation createAnimationImpl(View view, int x, int y, int width, int height) {
Animation.RELATIVE_TO_SELF,
.5f);
}
case SCALE_X: {
float fromValue = isReverse() ? 1.0f : 0.0f;
float toValue = isReverse() ? 0.0f : 1.0f;
return new ScaleAnimation(
fromValue,
toValue,
1f,
1f,
Animation.RELATIVE_TO_SELF,
.5f,
Animation.RELATIVE_TO_SELF,
0f);
}
case SCALE_Y: {
float fromValue = isReverse() ? 1.0f : 0.0f;
float toValue = isReverse() ? 0.0f : 1.0f;
return new ScaleAnimation(
1f,
1f,
fromValue,
toValue,
Animation.RELATIVE_TO_SELF,
0f,
Animation.RELATIVE_TO_SELF,
.5f);
}
default:
throw new IllegalViewOperationException(
"Missing animation for property : " + mAnimatedProperty);
Expand Down
Loading