This commit is contained in:
Eric van der Vlist 2022-10-19 13:04:56 +02:00
parent acbefa983d
commit b3a8f60f1e
2 changed files with 18 additions and 3 deletions

View File

@ -1,11 +1,16 @@
import react, { useRef, useState } from 'react';
import { atom, useAtom } from 'jotai';
import react, { useRef } from 'react';
import { useAtom } from 'jotai';
import { Point } from './types';
import './Handler.css';
import { handlersConfig } from './config';
import { Transformation, relativeCoordinateSystemAtom } from './Map';
import { relativeCoordinateSystemAtom } from './Map';
/**
*
* See also {@link components/map/Map!relativeCoordinateSystemAtom}.
*
*/
export interface HandlersProperties {}
/**
*
@ -18,6 +23,7 @@ export interface HandlersProperties {}
* * touchStart, touchEnd and touchCancel to track touch state
* * touchMove to shift the map (single finger) or shift and zoom (two fingers).
*
* Communication with the parent `<Map>` is done through {@link components/map/Map!relativeCoordinateSystemAtom}.
*/
export const Handlers: react.FC<HandlersProperties> = (
props: HandlersProperties

View File

@ -15,12 +15,21 @@ const initialCoordinateSystem = {
const coordinateSystemAtom = atom(initialCoordinateSystem);
/**
* Description of coordinates system transformation
*/
export interface Transformation {
/** New translation to apply */
deltaShift: Point | null;
/** Zoom factor to apply */
deltaZoom: number | null;
/** Center of the new zoom to apply */
zoomCenter: Point | null;
}
/**
* A write only atom to translate and zoom the coordinate system
*/
export const relativeCoordinateSystemAtom = atom(
null,
(get, set, t: Transformation) => {