You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by cx...@apache.org on 2017/03/07 06:21:55 UTC

[06/19] incubator-weex git commit: * [ios] fix view blur when animation

* [ios] fix view blur when animation


Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/f2141adc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/f2141adc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/f2141adc

Branch: refs/heads/0.11-dev
Commit: f2141adc8ea98ddf11025b054f1b7673c72f281f
Parents: 425fe9b
Author: acton393 <zh...@gmail.com>
Authored: Wed Feb 22 11:27:29 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Wed Feb 22 11:27:29 2017 +0800

----------------------------------------------------------------------
 .../WeexSDK/Sources/Module/WXAnimationModule.m    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/f2141adc/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
----------------------------------------------------------------------
diff --git a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
index 723de09..d2189dc 100644
--- a/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
+++ b/ios/sdk/WeexSDK/Sources/Module/WXAnimationModule.m
@@ -12,6 +12,7 @@
 #import "WXTransform.h"
 #import "WXUtility.h"
 
+const CGFloat sz = 1.00001;
 @interface WXAnimationModule ()
 
 @end
@@ -95,12 +96,16 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
        but they don\u2019t allow you to specify your own cubic B�zier curve. 
        CATransaction can be used instead to force these animations to use the supplied CAMediaTimingFunction to pace animations.
      **/
+    __weak typeof(self) weakSelf = self;
     [CATransaction begin];
     [CATransaction setAnimationTimingFunction:[WXConvert CAMediaTimingFunction:args[@"timingFunction"]]];
     [CATransaction setCompletionBlock:^{
         if (isUsingCAAnimation) {
             layer.transform = CATransform3DMakeAffineTransform(CGAffineTransformRotate(CGAffineTransformIdentity, rotateAngle));
         }
+        if ([weakSelf revertSZ]) {
+            layer.transform = CATransform3DScale(layer.transform, 1, 1, 1/sz);
+        }
         if (callback) {
             callback(@"SUCCESS");
         }
@@ -134,13 +139,9 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
                    I assume it's a bug in Core Animation.
                    Here comes the black magic: In the scale transformation, change the z parameter to anything different from 1.0, the jump is gone.
                    See http://stackoverflow.com/questions/27931421/cgaffinetransform-scale-and-translation-jump-before-animation
-                   
-                   if this make your view blur, you can specify the 'fixScale' option value 
+                 
+                   this maybe will blur your view, we will revert the sz when the animation finish.
                  **/
-                CGFloat sz = 1.00001;
-                if ([args[@"fixScale"] boolValue]) {
-                    sz = 1.0;
-                }
                 layer.transform = CATransform3DScale(transform, 1, 1, sz);
             }
             if (isAnimateBackgroundColor) {
@@ -166,4 +167,9 @@ WX_EXPORT_METHOD(@selector(transition:args:callback:))
     return radians;
 }
 
+- (BOOL)revertSZ
+{
+    return YES;
+}
+
 @end