mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-26 13:25:51 +08:00
Reverted commit D3401811
Summary: Currently on iOS animations are being performed on the JS thread. This ports animations over to the native thread and performs them natively. A lot of this work has already been done on Android, but this PR enables a few animation nodes that Android doesn't yet support such as Transform, Multiplication, and Addition nodes. Also there is a demo of the native animations added to the UIExplorer app. Closes https://github.com/facebook/react-native/pull/7884 Differential Revision: D3401811 Pulled By: nicklockwood fbshipit-source-id: 709e533243130153febef03ddd60d39e9fe70e3e
This commit is contained in:
committed by
Facebook Github Bot 1
parent
5ecdb252c3
commit
b29c938312
@@ -1,94 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
#import "RCTViewPropertyMapper.h"
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
#import "RCTBridge.h"
|
||||
#import "RCTUIManager.h"
|
||||
#import "RCTNativeAnimatedModule.h"
|
||||
|
||||
@implementation RCTViewPropertyMapper
|
||||
{
|
||||
CGFloat _translateX;
|
||||
CGFloat _translateY;
|
||||
CGFloat _scaleX;
|
||||
CGFloat _scaleY;
|
||||
CGFloat _rotation;
|
||||
RCTNativeAnimatedModule *_animationModule;
|
||||
}
|
||||
|
||||
- (instancetype)initWithViewTag:(NSNumber *)viewTag
|
||||
animationModule:(RCTNativeAnimatedModule *)animationModule
|
||||
{
|
||||
if ((self = [super init])) {
|
||||
_animationModule = animationModule;
|
||||
_viewTag = viewTag;
|
||||
_translateX = 0;
|
||||
_translateY = 0;
|
||||
_scaleX = 1;
|
||||
_scaleY = 1;
|
||||
_rotation = 0;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
|
||||
- (void)updateViewWithDictionary:(NSDictionary<NSString *, NSNumber *> *)updates
|
||||
{
|
||||
if (updates.count) {
|
||||
UIView *view = [_animationModule.bridge.uiManager viewForReactTag:_viewTag];
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
NSNumber *opacity = updates[@"opacity"];
|
||||
if (opacity) {
|
||||
view.alpha = opacity.doubleValue;
|
||||
}
|
||||
|
||||
NSNumber *scale = updates[@"scale"];
|
||||
if (scale) {
|
||||
_scaleX = scale.doubleValue;
|
||||
_scaleY = scale.doubleValue;
|
||||
}
|
||||
NSNumber *scaleX = updates[@"scaleX"];
|
||||
if (scaleX) {
|
||||
_scaleX = scaleX.doubleValue;
|
||||
}
|
||||
NSNumber *scaleY = updates[@"scaleY"];
|
||||
if (scaleY) {
|
||||
_scaleY = scaleY.doubleValue;
|
||||
}
|
||||
NSNumber *translateX = updates[@"translateX"];
|
||||
if (translateX) {
|
||||
_translateX = translateX.doubleValue;
|
||||
}
|
||||
NSNumber *translateY = updates[@"translateY"];
|
||||
if (translateY) {
|
||||
_translateY = translateY.doubleValue;
|
||||
}
|
||||
NSNumber *rotation = updates[@"rotate"];
|
||||
if (rotation) {
|
||||
_rotation = rotation.doubleValue;
|
||||
}
|
||||
|
||||
if (translateX || translateY || scale || scaleX || scaleY || rotation) {
|
||||
CATransform3D xform = CATransform3DMakeScale(_scaleX, _scaleY, 0);
|
||||
xform = CATransform3DTranslate(xform, _translateX, _translateY, 0);
|
||||
xform = CATransform3DRotate(xform, _rotation, 0, 0, 1);
|
||||
view.layer.allowsEdgeAntialiasing = YES;
|
||||
view.layer.transform = xform;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user