plus1tv / react-anime

✨ (ノ´ヮ´)ノ*:・゚✧ A super easy animation library for React!
https://codepen.io/collection/nrkjgo/
MIT License
1.55k stars 81 forks source link

Simple translateY will not work for the life of me. #59

Closed am8525 closed 4 years ago

am8525 commented 4 years ago

Really not sure what I'm doing wrong here. Just trying to get a basic translation going so I can start working with the library.

Any ideas?

render(){
        const {classes} = this.props;
        return (
            <div className={classes.landscape}>
                <div className={classes.centerpiece}>
                    <Anime translateY={100} loop={true} autoplay={true}>    
                        <Dot/>
                    </Anime>
                </div>
            </div>
        );
    }
am8525 commented 4 years ago

I've figured it out. A little bit of DOM manipulation did the trick:

componentDidMount(){
        const target = ReactDOM.findDOMNode(this);
        anime({
            targets: target.children[0].children,
            translateY: 100,
            loop: true
        });
    }

Note that it's the child of the child because the dot is within a nested div.