Skip to content

Animated.loop resets animatedValue #18028

Closed
@macrozone

Description

@macrozone

Is this a bug report?

yes

Have you read the Contributing Guidelines?

yes

Environment

Environment:
OS: macOS High Sierra 10.13.3
Node: 8.9.4
Yarn: 1.3.2
npm: 5.6.0
Watchman: 4.9.0
Xcode: Xcode 9.2 Build version 9C40b
Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
react: ^16.2.0 => 16.2.0
react-native: 0.53.0 => 0.53.0

Steps to Reproduce

class extends React.Component<*, *> {
  state = {
    hoverOffset: new Animated.Value(0)
  }
  startHovering() {
    console.log('start hover')
    Animated.loop(
      Animated.sequence([
        Animated.timing(this.state.hoverOffset, {
          toValue: 1,
          duration: 1000,
          easing: Easing.sin
        }),
        Animated.timing(this.state.hoverOffset, {
          toValue: 0.5,
          duration: 1000,
          easing: Easing.sin
        })
      ])
    ).start()
  }
  
   componentDidMount() {
     this.startHovering()
     this.state.hoverOffset.addListener(v => console.log(v))
  }

Expected Behavior

animation should set hoverOffset from 0 to 1 and then loop between 0.5 and 1

Actual Behavior

animation goes from 0 to 1 then 0.5 and then back to 0 and repeats (0 --> 1 --> 0.5 --> 0 --> 1 --> 0.5)

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: AnimatedRan CommandsOne of our bots successfully processed a command.StaleThere has been a lack of activity on this issue and it may be closed soon.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions