mirror of
https://github.com/mapbox/mapbox-gl-draw.git
synced 2026-02-01 14:34:52 +00:00
Simplify
This commit is contained in:
parent
06ebad26c4
commit
5daaa4a7cf
@ -1,7 +1,5 @@
|
||||
import type { ModeCTX } from '../types/types';
|
||||
|
||||
export const doubleClickZoom = {
|
||||
enable: (ctx: ModeCTX) => {
|
||||
enable: (ctx) => {
|
||||
setTimeout(() => {
|
||||
// First check we've got a map and some context.
|
||||
if (
|
||||
@ -17,7 +15,7 @@ export const doubleClickZoom = {
|
||||
ctx.map.doubleClickZoom.enable();
|
||||
}, 0);
|
||||
},
|
||||
disable: (ctx: ModeCTX) => {
|
||||
disable: (ctx) => {
|
||||
setTimeout(() => {
|
||||
if (!ctx.map || !ctx.map.doubleClickZoom) return;
|
||||
// Always disable here, as it's necessary in some cases.
|
||||
|
||||
@ -11,14 +11,14 @@ import { doubleClickZoom } from '../lib/double_click_zoom';
|
||||
import * as Constants from '../constants';
|
||||
import moveFeatures from '../lib/move_features';
|
||||
|
||||
import type { DirectSelectState, ModeCTX, MapMouseEvent, MapTouchEvent, DrawCoords, StrictFeature } from '../types/types';
|
||||
import type { DirectSelectState, DrawCustomMode, MapMouseEvent, MapTouchEvent, DrawCoords, StrictFeature } from '../types/types';
|
||||
|
||||
const isVertex = isOfMetaType(Constants.meta.VERTEX);
|
||||
const isMidpoint = isOfMetaType(Constants.meta.MIDPOINT);
|
||||
|
||||
type Event = MapMouseEvent | MapTouchEvent;
|
||||
|
||||
interface DirectSelectMode extends ModeCTX {
|
||||
interface DirectSelectMode extends DrawCustomMode {
|
||||
fireUpdate(): void;
|
||||
clickInactive(): void;
|
||||
fireActionable(state: DirectSelectState): void;
|
||||
@ -31,7 +31,7 @@ interface DirectSelectMode extends ModeCTX {
|
||||
dragFeature(state: DirectSelectState, e: Event, delta: { lng: number, lat: number }): void;
|
||||
dragVertex(state: DirectSelectState, e: Event, delta: { lng: number, lat: number }): void;
|
||||
clickActiveFeature(state: DirectSelectState): void;
|
||||
pathsToCoordinates(featureId: string, paths: number[]): DrawCoords;
|
||||
pathsToCoordinates(featureId: string, paths: string[]): DrawCoords;
|
||||
_start(state: DirectSelectState, e: Event): void;
|
||||
_select(state: DirectSelectState, e: Event): void;
|
||||
_end(state: DirectSelectState): void;
|
||||
@ -181,8 +181,6 @@ const DirectSelect: DirectSelectMode = {
|
||||
this.pathsToCoordinates(featureId, state.selectedCoordPaths)
|
||||
);
|
||||
this.setSelected(featureId);
|
||||
|
||||
console.log('does this have map?', this);
|
||||
doubleClickZoom.disable(this);
|
||||
|
||||
this.setActionableState({
|
||||
|
||||
@ -232,7 +232,7 @@ export interface DirectSelectState {
|
||||
dragMoving: boolean;
|
||||
feature: DrawPolygon;
|
||||
initialDragPanState?: boolean;
|
||||
selectedCoordPaths: number[];
|
||||
selectedCoordPaths: string[];
|
||||
}
|
||||
|
||||
export type DrawFeature =
|
||||
@ -308,6 +308,7 @@ interface DrawActionableEvent extends DrawEvent {
|
||||
|
||||
export interface DrawCustomModeThis {
|
||||
map: Map;
|
||||
_ctx: CTX;
|
||||
drawConfig: DrawOptions;
|
||||
setSelected(features?: DrawFeature[]): void;
|
||||
setSelectedCoordinates(
|
||||
@ -411,11 +412,6 @@ interface Modes {
|
||||
direct_select: DrawCustomMode;
|
||||
}
|
||||
|
||||
export interface ModeCTX extends DrawCustomMode {
|
||||
map: Map;
|
||||
_ctx: CTX;
|
||||
}
|
||||
|
||||
// Convert these to use imports from constants
|
||||
interface Constants {
|
||||
readonly modes: (typeof modes)[keyof typeof modes];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user