2021-02-06 13:32:38 +11:00
|
|
|
import React, { useContext } from "react";
|
2020-04-29 18:21:44 +10:00
|
|
|
|
|
|
|
|
const MapInteractionContext = React.createContext({
|
2020-05-21 16:46:50 +10:00
|
|
|
stageScale: 1,
|
|
|
|
|
stageWidth: 1,
|
|
|
|
|
stageHeight: 1,
|
|
|
|
|
setPreventMapInteraction: () => {},
|
|
|
|
|
mapWidth: 1,
|
|
|
|
|
mapHeight: 1,
|
2020-06-24 09:27:20 +10:00
|
|
|
interactionEmitter: null,
|
2020-04-29 18:21:44 +10:00
|
|
|
});
|
|
|
|
|
export const MapInteractionProvider = MapInteractionContext.Provider;
|
|
|
|
|
|
2021-02-06 13:32:38 +11: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 18:21:44 +10:00
|
|
|
export default MapInteractionContext;
|