-
Notifications
You must be signed in to change notification settings - Fork 1
/
ManualCamera.tsx
29 lines (25 loc) · 863 Bytes
/
ManualCamera.tsx
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
import React, { FunctionComponent } from 'react';
import { CameraEventListener } from '../CameraEventListener/CameraEventListener';
import { ManualCameraSettings } from './ManualCamera.types';
import { useHandlers } from './ManualCamera.useHandlers';
import { useSyncPosition } from './ManualCamera.useSyncPosition';
/**
* This component is used to manually control the camera position and zoom of the tilemap.
*
* Use clickable prop to enable or disable click controls.
*
* @public
*
* @param props ManualCameraProps
*/
export const ManualCamera: FunctionComponent<ManualCameraSettings> = (props) => {
useSyncPosition(props.position, props.zoom);
const clickable = props.clickable ?? true;
const handlers = useHandlers();
return (
<>
{clickable && <CameraEventListener handlers={handlers} />}
{props.children}
</>
);
};