{"size": 944, "ext": "js", "max_stars_repo_path": "src/triggers/ScrollPositionAnimation.js", "max_stars_repo_name": "ChefSteps/react-native-declan", "max_stars_repo_stars_event_min_datetime": "2017-11-03T20:41:32.000Z", "max_stars_repo_stars_event_max_datetime": "2019-03-29T08:55:48.000Z", "max_issues_repo_path": "src/triggers/ScrollPositionAnimation.js", "max_issues_repo_name": "ChefSteps/react-native-declan", "max_issues_repo_issues_event_min_datetime": "2017-11-22T22:57:24.000Z", "max_issues_repo_issues_event_max_datetime": "2017-11-22T23:19:46.000Z", "max_forks_repo_path": "src/triggers/ScrollPositionAnimation.js", "max_forks_repo_name": "ChefSteps/react-native-declan", "max_forks_repo_forks_event_min_datetime": "2018-01-22T19:05:36.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-06T02:33:42.000Z"}
{"max_stars_count": 9, "max_issues_count": 2, "max_forks_count": 3, "avg_line_length": 21.4545454545, "max_line_length": 51, "alphanum_fraction": 0.5953389831}
// @flow

import { Animated } from 'react-native';
import BaseTrigger from './BaseTrigger';
import ScrollDriver from '../drivers/ScrollDriver';

type Props = {
  from: number,
  to: number,
  driver: ScrollDriver,
};

class ScrollPositionAnimation extends BaseTrigger {
  constructor(props: Props) {
    super(props);
    this.animators = [];
    this.from = props.from;
    this.to = props.to;
    this.driver = props.driver;
  }

  componentDidMount() {
    this.setState({
      propertiesToAppend: {
        driverValue: (this.from < this.to)
          ? this.driver.value.interpolate({
              inputRange: [this.from, this.to],
              outputRange: [0, 1],
            })
          : this.driver.value.interpolate({
            inputRange: [this.to, this.from],
            outputRange: [1, 0],
          }),
      }
    });
  }

  from: number;
  to: number;
  driver: ScrollDriver;
}

export default ScrollPositionAnimation;
