<commit_before>import React from 'react';
import {Spring} from '../src/Spring';
import {range} from '../src/utils';

const Demo = React.createClass({
  getInitialState() {
    return {mouse: [250, 300]};
  },

  handleMouseMove({pageX, pageY}) {
    this.setState({mouse: [pageX, pageY]});
  },

  handleTouchMove({touches}) {
    this.handleMouseMove(touches[0]);
  },

  getValues(currentPositions) {
    // currentPositions of `null` means it's the first render for Spring
    if (currentPositions == null) {
      return {val: range(6).map(() => [0, 0])};
    }
    const endValue = currentPositions.val.map((_, i) => {
      // hack. We're getting the currentPositions of the previous ball, but in
      // reality it's not really the "current" position. It's the last render's.
      // If we want to get the real current position, we'd have to compute it
      // now, then read into it now. This gets very tedious with this API.
      return i === 0 ? this.state.mouse : currentPositions.val[i - 1];<commit_msg>Current positions is undefined at first render<commit_after>import React from 'react';
import {Spring} from '../src/Spring';
import {range} from '../src/utils';

const Demo = React.createClass({
  getInitialState() {
    return {mouse: [250, 300]};
  },

  handleMouseMove({pageX, pageY}) {
    this.setState({mouse: [pageX, pageY]});
  },

  handleTouchMove({touches}) {
    this.handleMouseMove(touches[0]);
  },

  getValues(currentPositions) {
    // currentPositions of `undefined` means it's the first render for Spring
    if (currentPositions === undefined) {
      return {val: range(6).map(() => [0, 0])};
    }
    const endValue = currentPositions.val.map((_, i) => {
      // hack. We're getting the currentPositions of the previous ball, but in
      // reality it's not really the "current" position. It's the last render's.
      // If we want to get the real current position, we'd have to compute it
      // now, then read into it now. This gets very tedious with this API.
      return i === 0 ? this.state.mouse : currentPositions.val[i - 1];
{'fraction_non_alphanumeric': 0.14073006724303555, 'fraction_numerical': 0.011527377521613832, 'mean_word_length': 3.2251521298174444, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946089', 'n_tokens_mistral': 665, 'n_tokens_neox': 630, 'n_words': 215}