2021-02-05 21:32:38 -05:00
|
|
|
import React, { useContext } from "react";
|
2020-04-29 04:21:44 -04:00
|
|
|
|
|
|
|
const MapInteractionContext = React.createContext({
|
2020-05-21 02:46:50 -04:00
|
|
|
stageScale: 1,
|
|
|
|
stageWidth: 1,
|
|
|
|
stageHeight: 1,
|
|
|
|
setPreventMapInteraction: () => {},
|
|
|
|
mapWidth: 1,
|
|
|
|
mapHeight: 1,
|
2020-06-23 19:27:20 -04:00
|
|
|
interactionEmitter: null,
|
2020-04-29 04:21:44 -04:00
|
|
|
});
|
|
|
|
export const MapInteractionProvider = MapInteractionContext.Provider;
|
|
|
|
|
2021-02-05 21:32:38 -05:00
|
|
|
export function useMapInteraction() {
|
|
|
|
const context = useContext(MapInteractionContext);
|
|
|
|
if (context === undefined) {
|
|
|
|
throw new Error(
|
|
|
|
"useMapInteraction must be used within a MapInteractionProvider"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return context;
|
|
|
|
}
|
|
|
|
|
2020-04-29 04:21:44 -04:00
|
|
|
export default MapInteractionContext;
|