Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ease animation from right end of the screen #24

Open
sruthisripathi opened this issue Feb 28, 2018 · 0 comments
Open

ease animation from right end of the screen #24

sruthisripathi opened this issue Feb 28, 2018 · 0 comments

Comments

@sruthisripathi
Copy link

sruthisripathi commented Feb 28, 2018

I wrote this using react-smooth which kind of works like a collapsible sidebar on the left

import React, { Component } from 'react';
import Animate from 'react-smooth';

class SimpleAnime extends Component {
  constructor(props) {
    super(props);

    this.state = {
      from : -400,
      to: -400
    };
  }

  handleClick() {
    if(this.state.to == this.state.from) {
      this.setState({
        from: -400,
        to: -5
      });
    }
    else {
      this.setState({
        from: this.state.to,
        to: this.state.from
      });
    }
  }

  render() {
    return (
      <div className="simple">
        <button onClick={this.handleClick.bind(this)}>click me!</button>
        <Animate from={{ x: this.state.from }} to={{ x: this.state.to }}>
          {({ x }) => (
            <div
              style={{
                width: 300,
                height: 800,
                backgroundColor: 'green',
                transform: `translate(${x}px, 0)`,
              }}
            >
            </div>
          )}
        </Animate>
      </div>
    );
  }
}

export default SimpleAnime;

How to make the collapsible sidebar on the right ?
I mean what values should to and from pros be given such that the div moves from right end to the width of div ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant