weex icon indicating copy to clipboard operation
weex copied to clipboard

关于animation的一个问题

Open zjalen opened this issue 9 years ago • 3 comments

在测试animation的时候发现一个问题,ios版本的(最新sdk)翻转动画,如果转动角度超过180度,只能顺时针,不能逆时针,180度内正反转都没问题,超过之后反转没有任何动作,例如下面代码

<template>
    <div style="justify-content: center; align-items: center">
        <div id="target" onclick="{{doAnim}}"
             style="width: 240px; height: 240px; background-color: #F0AD4E;justify-content: center; align-items: center;">
            <text style="text-align: center;color: white;font-size: 80px">Click</text>
        </div>
    </div>
</template>
<script>
    module.exports = {
        data: {
            rotate : '0deg'
        },
        methods: {
            doAnim: function () {
                var self = this;
                var animation = require('@weex-module/animation');
                var target = this.$el('target');
                self.rotate = self.rotate === '0deg' ? '270deg' : '0deg';
                var options = {
                    styles: {
                        transform: 'rotate(' + self.rotate + ')',
                    },
                    duration: 1000,
                };
                var callback = function () {
                    nativeLog('animation complete.');
                };
                animation.transition(target, options, callback);
            }
        }
    }
</script>

在0-270的时候是正常的,270-0的时候不动,再到0-270的时候,会突然从270调到0再开始0-270。我在android上测试是正常的,不知道是不是bug?

zjalen avatar Dec 29 '16 03:12 zjalen

@Jinjiang 希望关注一下

zjalen avatar Dec 29 '16 03:12 zjalen

http://dotwe.org/cad4d4cd051ab3e565f3cd42bbcac73b 实测,HTML5、Android 没有问题,iOS 下有问题 @cxfeng1

Jinjiang avatar Dec 29 '16 05:12 Jinjiang

@myyeshang 目前对于大于180度的旋转, iOS底层实现有bug, 使用的是CAAnimation去绕过, 详见stack overflow的讨论 ,两种动画使用方式无法混合记录, 目前采用了记录上次旋转角度的方式去修复, 参见 #2182 。

这个方法可能暂时无法完美解决 > 180 以及 < 180 渲染角度多次混用的情况, 对于你的demo, 应该可以解决。如有其他问题请直接回复, 谢谢。

cxfeng1-zz avatar Jan 09 '17 12:01 cxfeng1-zz