React Native 按钮扩散效果

【看效果】


QQ20170706-150504.gif

【贴上代码】动画代码

 componentDidMount() {
        this.loopTouchAnimated();
    }

    loopTouchAnimated() {

        Animated.timing(this.state.spreadAni, {
            toValue: 1,
            easing: Easing.linear,
            duration: 2000,

        }).start(
            ()=>{
                this.state.spreadAni.setValue(0);

            }
        );
    }

【渲染代码】

 math = this.state.spreadAni.interpolate({
            inputRange: [0, 1],
            outputRange: [100, 200],
        });
        alph = this.state.spreadAni.interpolate({
            inputRange: [0, 1],
            outputRange: ['rgba(227,111,83,1)', 'rgba(227,111,83,0)'],
        });

        return (
            <View style={styles.container}>
                <Animated.View
                    style={{
                        borderColor: alph,
                        borderWidth: 2,
                        width: math,
                        height: math,
                        borderRadius: math,
                        backgroundColor: alph,
                        justifyContent: 'center',
                        alignItems: 'center'

                    }}
                >
                    <TouchableOpacity
                        onPress={()=> {
                            this.loopTouchAnimated();
                        }}
                    >
                        <Image
                            style={styles.imageStyle}
                            source={require('../tabbar/panresponder-target.png')}

                        />
                    </TouchableOpacity>

                </Animated.View>

            </View>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,964评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,267评论 4 61
  • 大家好,今天来聊聊我最近对学习知识这件事情的体会。 人生中总会遇到一些坑,对于学习这件事情也一样。遇到坑不可怕,可...
    DingZhang阅读 555评论 1 1