css - 在一个元素上 react native 动画多个动画

标签 css reactjs react-native animation react-animated

有没有办法在一个动画 View 上有多个动画,改变相同的 css 属性?

this.expandAnimation = new Animated.Value(50);
this.shrinkAnimation = new Animated.Value(200);

Animated.sequence([
  Animated.timing(this.expandAnimation, {
    toValue: 200,
    duration: 1000
  }),
  Animated.timing(this.shrinkAnimation, {
    toValue: 50,
    duration: 1000
  })
]),

  <Animated.View style={[styles.box, { width: this.ExpandAnimation }]}> // What value to bind to width?
    <View>
    </View>
  </Animated.View>

最佳答案

由 Federkun 回答。您使用单个动画值。

this.expandAndShrinkAnimation = new Animated.Value(50);

Animated.sequence([
  Animated.timing(this.expandAndShrinkAnimation, {
    toValue: 200,
    duration: 1000
  }),
  Animated.timing(this.expandAndShrinkAnimation, {
    toValue: 50,
    duration: 1000
  })
]),

  <Animated.View style={[styles.box, { width: this.expandAndShrinkAnimation }]}> // What value to bind to width?
    <View>
    </View>
  </Animated.View>


关于css - 在一个元素上 react native 动画多个动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59079786/

相关文章:

css - Scriptaculous Effect.Appear glitch onmouseover

css - 如何在 Material UI 的表格列中将图像移到文本左侧?

reactjs - Apollo GraphQL (React) refetchQueries/突变后更新不更新存储

reactjs - React 选项卡的 shouldComponentUpdate

utf-8 - react native : How to decode base64 encoded string?

ios - react-native-image-picker 不从相机返回数据

javascript - jQuery 不向元素添加类

css - 引用 Assets 供应商目录中的图像 url

javascript - 使用 javascript 控制 HTML 5 视频 Controller ?

javascript - 通过使用 aws-sdk 在 s3 Bucket 上上传图像来 react native