react-smooth icon indicating copy to clipboard operation
react-smooth copied to clipboard

easing bugs

Open lemonleon opened this issue 7 years ago • 4 comments

  1. easing 'spring' not support in steps, it will trigger a warning~ like this
const steps = [{
  style: {
    opacity: 0,
  },
  duration: 400,
  easing: 'ease-in-out'
}, {
  style: {
    opacity: 1,
    transform: 'translate(0, 0)',
  },
  duration: 1000,
  easing: 'ease-out'
}, {
  style: {
    transform: 'translate(100px, 100px)',
  },
  duration: 1200,
  easing: 'spring'
}];

render() {
    return (
      <div className="simple">
        <button onClick={this.handleClick.bind(this)}>click me!</button>
        <Animate steps={steps} >
          <div style={{
                        width: 100,
                        height: 100,
                        backgroundColor: 'red'
                    }}
                    >
                    </div>
        </Animate>
      </div>
    );
  }
  1. if use steps, children is a function,animation will not be properly implemented' like this
const steps = [{
  style: {
    opacity: 0,
  },
  duration: 400,
  easing: 'ease-in-out'
}, {
  style: {
    opacity: 1,
    transform: 'translate(0, 0)',
  },
  duration: 1000,
  easing: 'ease-out'
}, {
  style: {
    transform: 'translate(100px, 100px)',
  },
  duration: 1200,
  easing: 'ease-in'
}];

render() {
    return (
      <div className="simple">
        <button onClick={this.handleClick.bind(this)}>click me!</button>
        <Animate steps={steps} onAnimationEnd={()=>{console.log('aaa');}}>
           {
                   (json) => {
                        console.log(json);

                        return (
                              <div style={{
                                width: 100,
                                height: 100,
                                backgroundColor: 'red'
                                }}
                               >
                               </div>
                         );
                   }
            }
        </Animate>
      </div>
    );
  }

lemonleon avatar Jun 08 '17 12:06 lemonleon

Further to this, there is a bunch of code in easing.js that seems to want to create a JS-based animation, but then in Animate.js a css style animation easing style is passed. I am still learning React but I'd like to be able to have bezier easing so I've been trying to change it but it is not proving easy...

Gazareth avatar Jan 14 '18 23:01 Gazareth

I've managed to get bezier easing working in my fork, so I can write:

animationEasing= 'cubic-bezier(0.165, 0.84, 0.44, 1)'

And it gets passed through to the graph components from recharts.

I also had to change the PropTypes in recharts TreeChart.js to allow all strings, but I'll leave that as a local change for now...

Gazareth avatar Jan 15 '18 00:01 Gazareth

@Gazareth PR would be much appreciated. I'd like to use cubic-bezier as well, given that the docs say they support any CSS easing function.

paul-sachs avatar Apr 29 '18 21:04 paul-sachs

easing could be a function like configureBezier(0.1, 0.1, 0.5, 0.8); in docs or u can write any easing function u want

jasonHzq avatar Oct 16 '19 03:10 jasonHzq