我正在使用react-modal创建模态,并尝试从页面底部滑动模态。为此,我正在尝试react-motion TransitionMotion组件。我的代码是:
{ 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>
}
其中的getStyles是:
getStyles = () => ({ opacity: spring(1), scale: spring(1) });
但这无法正常工作,因为模态组件。