aboutsummaryrefslogtreecommitdiffstats
path: root/packages/instant/src/components/animations/slide_animation.tsx
blob: 6ac47e9a66d308d5613a24210372df367f50fe60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import * as React from 'react';

import { OptionallyScreenSpecific } from '../../style/media';
import { SlideAnimationState } from '../../types';

import { PositionAnimation, PositionAnimationSettings } from './position_animation';

export interface SlideAnimationProps {
    animationState: SlideAnimationState;
    slideInSettings: OptionallyScreenSpecific<PositionAnimationSettings>;
    slideOutSettings: OptionallyScreenSpecific<PositionAnimationSettings>;
    zIndex?: OptionallyScreenSpecific<number>;
    height?: string;
    onAnimationEnd?: () => void;
}

export const SlideAnimation: React.StatelessComponent<SlideAnimationProps> = props => {
    if (props.animationState === 'none') {
        return <React.Fragment>{props.children}</React.Fragment>;
    }
    const positionSettings = props.animationState === 'slidIn' ? props.slideInSettings : props.slideOutSettings;
    return (
        <PositionAnimation
            onAnimationEnd={props.onAnimationEnd}
            height={props.height}
            positionSettings={positionSettings}
            zIndex={props.zIndex}
        >
            {props.children}
        </PositionAnimation>
    );
};

SlideAnimation.displayName = 'SlideAnimation';