import * as _ from "lodash"; import * as React from "react"; import { CSSTransition } from 'react-transition-group'; import { getImageSrc } from "../../utilities/image"; import { Image } from "../Image"; export enum MapExtra { Sleepy = "sleepy-pin", SleepyCamera = "sleepy-camera", BrokenPicture = "broken-picture", Card = "card-pin", } interface IMapProps { mount: boolean; extra?: MapExtra; extraBounceAnimation?: boolean; imagePrefix?: string; onEntering?: () => void; onEnter?: () => void; /** * This is a useful hook to ensure that subsequent transitions * only occur after the full map asset has loaded */ onMapLoad?: () => void; } interface IMapState { mount: boolean; } const defaultMapState: IMapState = { mount: false, }; export class Map extends React.Component { public state: IMapState = defaultMapState; public componentDidMount() { if (this.props.mount) { setTimeout(() => { this.setState({ mount: true, }); }, 1); } } public componentDidUpdate(prevProps: IMapProps) { if (this.props.mount !== prevProps.mount) { this.setState({ mount: this.props.mount, }); } } public render() { return ( {state => (
{this.props.extra && (
{this.renderExtra()}
)}
)}
) } private renderExtra = () => { switch (this.props.extra) { case MapExtra.BrokenPicture: case MapExtra.Sleepy: case MapExtra.SleepyCamera: return ( ); case MapExtra.Card: return ( <> ); } } }