import * as React from 'react'; import styles from './AnimationExample.scss'; import { NodeGroup } from 'react-move'; import { Button } from '../../../buttons/Button/Button'; interface IState { items: number[]; } export default class AnimationExample extends React.Component { protected _count: number = 0; constructor (props: any) { super(props); this.state = { items: this.makeItems(), }; } shuffle (array: any[]) { var currentIndex = array.length, temporaryValue, randomIndex; // While there remain elements to shuffle... while (0 !== currentIndex) { // Pick a remaining element... randomIndex = Math.floor(Math.random() * currentIndex); currentIndex -= 1; // And swap it with the current element. temporaryValue = array[currentIndex]; array[currentIndex] = array[randomIndex]; array[randomIndex] = temporaryValue; } return array; } removeItem = (index: number) => { index = index || 0; this.setState({ items: this.state.items.filter((_, i) => i !== index), }); } addOne = () => { this.setState(state => { const items = [this._count++].concat(state.items); return { items, }; }); } makeItems () { let items = []; for (let i = 0; i < 10; i++) { items.push(this._count++); } return items; } render () { let { items } = this.state; return (
d} start={d => ({ height: [0], opacity: [0], })} enter={d => ({ height: [40], opacity: [1], })} update={d => ({ height: [40], opacity: [1], })} leave={d => ({ height: [0], opacity: [0], })} > {(group) => (
{group.map((node, index) => (
{node.key}
))}
)}
); } }