diff options
author | fragosti <francesco.agosti93@gmail.com> | 2019-01-03 02:07:02 +0800 |
---|---|---|
committer | fragosti <francesco.agosti93@gmail.com> | 2019-01-03 02:07:02 +0800 |
commit | 1ceb3c96645fd3682c59459fdce996cdf5f216cf (patch) | |
tree | d7c656316045dd2da21a8512d0a3c569ec935bba /packages/instant/src/components/sliding_panel.tsx | |
parent | 4252a760f072da907d1b542e3bb9917db3f22b07 (diff) | |
download | dexon-0x-contracts-1ceb3c96645fd3682c59459fdce996cdf5f216cf.tar.gz dexon-0x-contracts-1ceb3c96645fd3682c59459fdce996cdf5f216cf.tar.zst dexon-0x-contracts-1ceb3c96645fd3682c59459fdce996cdf5f216cf.zip |
feat: unmount the token selector when its not displaying
Diffstat (limited to 'packages/instant/src/components/sliding_panel.tsx')
-rw-r--r-- | packages/instant/src/components/sliding_panel.tsx | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/packages/instant/src/components/sliding_panel.tsx b/packages/instant/src/components/sliding_panel.tsx index 33a483662..9b09a0d80 100644 --- a/packages/instant/src/components/sliding_panel.tsx +++ b/packages/instant/src/components/sliding_panel.tsx @@ -30,42 +30,44 @@ Panel.displayName = 'Panel'; export interface SlidingPanelProps extends PanelProps { animationState: SlideAnimationState; + onAnimationEnd?: () => void; } -export const SlidingPanel: React.StatelessComponent<SlidingPanelProps> = props => { - if (props.animationState === 'none') { - return null; +export class SlidingPanel extends React.PureComponent<SlidingPanelProps> { + public render(): React.ReactNode { + if (this.props.animationState === 'none') { + return null; + } + const { animationState, onAnimationEnd, ...rest } = this.props; + const slideAmount = '100%'; + const slideUpSettings: PositionAnimationSettings = { + duration: '0.3s', + timingFunction: 'ease-in-out', + top: { + from: slideAmount, + to: '0px', + }, + position: 'absolute', + }; + const slideDownSettings: PositionAnimationSettings = { + duration: '0.3s', + timingFunction: 'ease-out', + top: { + from: '0px', + to: slideAmount, + }, + position: 'absolute', + }; + return ( + <SlideAnimation + slideInSettings={slideUpSettings} + slideOutSettings={slideDownSettings} + animationState={animationState} + height="100%" + onAnimationEnd={onAnimationEnd} + > + <Panel {...rest} /> + </SlideAnimation> + ); } - const { animationState, ...rest } = props; - const slideAmount = '100%'; - const slideUpSettings: PositionAnimationSettings = { - duration: '0.3s', - timingFunction: 'ease-in-out', - top: { - from: slideAmount, - to: '0px', - }, - position: 'absolute', - }; - const slideDownSettings: PositionAnimationSettings = { - duration: '0.3s', - timingFunction: 'ease-out', - top: { - from: '0px', - to: slideAmount, - }, - position: 'absolute', - }; - return ( - <SlideAnimation - slideInSettings={slideUpSettings} - slideOutSettings={slideDownSettings} - animationState={animationState} - height="100%" - > - <Panel {...rest} /> - </SlideAnimation> - ); -}; - -SlidingPanel.displayName = 'SlidingPanel'; +} |