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

how to use react-motion library with modals #572

Open
rajatgalav opened this issue Sep 24, 2019 · 1 comment
Open

how to use react-motion library with modals #572

rajatgalav opened this issue Sep 24, 2019 · 1 comment

Comments

@rajatgalav
Copy link

rajatgalav commented Sep 24, 2019

I am using react-modal to create modals, and trying to slide the modal from bottom of page. For that i am trying react-motion TransitionMotion Component. My code is:

{ this.state.openNumberPopup &&
          <TransitionMotion 
            styles={[{key: 'key',style: this.getStyles()}] }
          >
            { (interpolated) =>
              <div>
                { interpolated.map(({ key, style, data }) =>
                <NumberPopup
                  key={`${key}-transition`}
                  style={{opacity: style.opacity,transform: `scale(${style.scale})`}}
                  openNumberPopup={this.state.openNumberPopup}
                  toggleNumberPopup={this.toggleNumberPopup}
                  handleChange={this.handleChange}
                  updateNumber={this.updateNumber}
                  disableSubmit={this.state.disableSubmit}
                />
                ) }
              </div>
      }
  </TransitionMotion>
}

where getStyles is
getStyles = () => ({ opacity: spring(1), scale: spring(1) });
but this is not working because modal component.

@ashr81
Copy link

ashr81 commented Oct 1, 2019

Instead of TransitionMotion use Motion component from react-motion. something like this.

<Motion
  defaultStyle={{y: -100, opacity: 0}}
  style={presentStyle}
  willLeave={willLeave}>
   {(style) => (< NumberPopup style={
    {
       opacity: style.opacity,
       transform: `translate(-50%, ${style.y}px)`,
       WebkitTransform: `translate(-50%, ${style.y}px)`
     }
   } {...props}>
      {children}</NumberPopup >
    )}
</Motion>

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

2 participants