terra-draw 1.0.0-beta.6 → 1.0.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare class AdapterListener<Callback extends (...args: any[]) => any> {
|
|
2
|
+
name: string;
|
|
3
|
+
callback: (...args: any[]) => any;
|
|
4
|
+
registered: boolean;
|
|
5
|
+
register: any;
|
|
6
|
+
unregister: any;
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new AdapterListener instance with the provided configuration.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} config - The configuration object for the listener.
|
|
11
|
+
* @param {string} config.name - The name of the event listener.
|
|
12
|
+
* @param {Function} config.callback - The callback function to be called when the event is triggered.
|
|
13
|
+
* @param {Function} config.unregister - The function to unregister the event listeners.
|
|
14
|
+
* @param {Function} config.register - The function to register the event listeners.
|
|
15
|
+
*/
|
|
16
|
+
constructor({ name, callback, unregister, register, }: {
|
|
17
|
+
name: string;
|
|
18
|
+
callback: Callback;
|
|
19
|
+
unregister: (callbacks: Callback) => void;
|
|
20
|
+
register: (callback: Callback) => void;
|
|
21
|
+
});
|
|
22
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Project, Unproject, TerraDrawCallbacks, TerraDrawChanges, TerraDrawMouseEvent, SetCursor, TerraDrawStylingFunction, GetLngLatFromEvent, TerraDrawAdapter } from "../../common";
|
|
2
|
+
import { AdapterListener } from "./adapter-listener";
|
|
3
|
+
type BasePointerListener = (event: PointerEvent) => void;
|
|
4
|
+
type BaseKeyboardListener = (event: KeyboardEvent) => void;
|
|
5
|
+
type BaseMouseListener = (event: MouseEvent) => void;
|
|
6
|
+
export type BaseAdapterConfig = {
|
|
7
|
+
coordinatePrecision?: number;
|
|
8
|
+
minPixelDragDistanceDrawing?: number;
|
|
9
|
+
minPixelDragDistance?: number;
|
|
10
|
+
minPixelDragDistanceSelecting?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare abstract class TerraDrawBaseAdapter implements TerraDrawAdapter {
|
|
13
|
+
constructor(config: BaseAdapterConfig);
|
|
14
|
+
protected _minPixelDragDistance: number;
|
|
15
|
+
protected _minPixelDragDistanceDrawing: number;
|
|
16
|
+
protected _minPixelDragDistanceSelecting: number;
|
|
17
|
+
protected _lastDrawEvent: TerraDrawMouseEvent | undefined;
|
|
18
|
+
protected _coordinatePrecision: number;
|
|
19
|
+
protected _heldKeys: Set<string>;
|
|
20
|
+
protected _listeners: AdapterListener<BasePointerListener | BaseKeyboardListener | BaseMouseListener>[];
|
|
21
|
+
protected _dragState: "not-dragging" | "pre-dragging" | "dragging";
|
|
22
|
+
protected _currentModeCallbacks: TerraDrawCallbacks | undefined;
|
|
23
|
+
abstract getMapEventElement(): HTMLElement;
|
|
24
|
+
protected getButton(event: PointerEvent | MouseEvent): "neither" | "left" | "middle" | "right";
|
|
25
|
+
protected getMapElementXYPosition(event: PointerEvent | MouseEvent): {
|
|
26
|
+
containerX: number;
|
|
27
|
+
containerY: number;
|
|
28
|
+
};
|
|
29
|
+
protected getDrawEventFromEvent(event: PointerEvent | MouseEvent): TerraDrawMouseEvent | null;
|
|
30
|
+
/**
|
|
31
|
+
* Registers the provided callbacks for the current drawing mode and attaches
|
|
32
|
+
* the necessary event listeners.
|
|
33
|
+
* @param {TerraDrawCallbacks} callbacks - An object containing callback functions
|
|
34
|
+
* for handling various drawing events in the current mode.
|
|
35
|
+
*/
|
|
36
|
+
register(callbacks: TerraDrawCallbacks): void;
|
|
37
|
+
/**
|
|
38
|
+
* Gets the coordinate precision. The coordinate precision is the number of decimal places in geometry
|
|
39
|
+
* coordinates stored in the store.
|
|
40
|
+
* @returns {number} The coordinate precision.
|
|
41
|
+
*/
|
|
42
|
+
getCoordinatePrecision(): number;
|
|
43
|
+
private getAdapterListeners;
|
|
44
|
+
/**
|
|
45
|
+
* Unregisters the event listeners for the current drawing mode.
|
|
46
|
+
* This is typically called when switching between drawing modes or
|
|
47
|
+
* stopping the drawing process.
|
|
48
|
+
*/
|
|
49
|
+
unregister(): void;
|
|
50
|
+
abstract clear(): void;
|
|
51
|
+
abstract project(...args: Parameters<Project>): ReturnType<Project>;
|
|
52
|
+
abstract unproject(...args: Parameters<Unproject>): ReturnType<Unproject>;
|
|
53
|
+
abstract setCursor(...args: Parameters<SetCursor>): ReturnType<SetCursor>;
|
|
54
|
+
abstract getLngLatFromEvent(...event: Parameters<GetLngLatFromEvent>): ReturnType<GetLngLatFromEvent>;
|
|
55
|
+
abstract setDraggability(enabled: boolean): void;
|
|
56
|
+
abstract setDoubleClickToZoom(enabled: boolean): void;
|
|
57
|
+
abstract render(changes: TerraDrawChanges, styling: TerraDrawStylingFunction): void;
|
|
58
|
+
}
|
|
59
|
+
export {};
|