react 型:

<ScrollView style={styles.container}>
    <Svg
      height="100"
      width="100">
        <Circle
          cx="50"
          cy="50"
          r="50"
          stroke="blue"
          strokeWidth="2.5"
          fill="green"/>
      </Svg>
</ScrollView>

我想用动画制作圆形比例.价值我试过:

    let AnimatedScrollView = Animated.createAnimatedComponent(ScrollView);
    let AnimatedCircle = Animated.createAnimatedComponent(Circle);

    <ScrollView style={styles.container}>
            <Svg
              height="100"
              width="100">
                <AnimatedCircle
                  cx="50"
                  cy="50"
                  r={this.state.animator}
                  stroke="blue"
                  strokeWidth="2.5"
                  fill="green"/>
              </Svg>
        </ScrollView>

然后毫无错误地回闪.

我该怎么办?


update 2016.8.24

我找到了一种新的方法来代替requestAnimationFrame:

建造师:

this.state = {
      animator: new Animated.Value(0),
      radius: 1,
    };

    this.state.animator.addListener((p) => {
      this.setState({
        radius: p.value,
      });
    });

提供:

<Circle
    cx="50"
    cy="50"
    r={this.state.radius}
    stroke="blue"
    strokeWidth="2.5"
    fill="green"/>

但是这里the guides给出了一些建议,因为它可能会对future 的性能产生影响.

那么最好的方法是什么?

推荐答案

没有更好的答案,我通过向Animated.Value变量添加listener来实现,您可以从我的问题描述中获得更多信息.

React-native相关问答推荐

在Reaction Native With EXPO中播放来自OpenAI TTS API的音频响应

什么是 expoClientId?

在 React Native 中使用 Flatlist scrollView 时的模式关闭

用图像 react native 动画进度条

React Native - 为什么我们对 Image 组件使用 tintColor 属性?

react-native-snap-carousel 无法正确渲染

为什么会出现此错误:Invariant Violation: Cannot update during an existing state transition

设置 rootView.appProperties 不会重新渲染根组件

fetch API 总是返回 {"_U": 0, "_V": 0, "_W": null, "_X": null}

使用 Android NDK 在 C 或 C++ 中创建 react-native Native Module?

Realm 和 React Native - 实现自动更新的最佳实践?

React Navigation - 标题的渐变 colored颜色

有没有办法改变 IOS 标题上react-navigation 的默认后退按钮 colored颜色 ?

我们如何将 Firebase Analytics 与基于 expo 的 react-native 应用程序一起使用

React-Native: measure测量一个视图

React-Native:FlatList onRefresh not called on pull up.

我可以将标题传递给图像源吗?

如何在自定义组件上使用 onPress?

在 React 中调用 getDerivedStateFromProps 中的方法

Android 是否支持 React Native 的 LayoutAnimation?