diff --git a/leaflet/index.d.ts b/leaflet/index.d.ts index c3a53f60b3..80f42e9961 100644 --- a/leaflet/index.d.ts +++ b/leaflet/index.d.ts @@ -33,13 +33,13 @@ declare namespace L { static testProp(props: String[]): String|boolean/*=false*/; static setTransform(el: HTMLElement, offset: Point, scale?: Number):void; static setPosition(el: HTMLElement, position: Point):void; - static getPosition(el: HTMLElement): Point - static disableTextSelection(): void - static enableTextSelection(): void - static disableImageDrag(): void - static enableImageDrag(): void - static preventOutline(el: HTMLElement): void - static restoreOutline(): void + static getPosition(el: HTMLElement): Point; + static disableTextSelection(): void; + static enableTextSelection(): void; + static disableImageDrag(): void; + static enableImageDrag(): void; + static preventOutline(el: HTMLElement): void; + static restoreOutline(): void; } export interface CRS { @@ -203,7 +203,7 @@ declare namespace L { * with an object (e.g. the user clicks on the map, causing the map to fire * 'click' event). */ - export interface Evented extends Class { + export abstract class Evented extends Class { /** * Adds a listener function (fn) to a particular event type of the object. * You can optionally specify the context of the listener (object the this @@ -339,6 +339,21 @@ declare namespace L { hasEventListeners(type: string): boolean; } + /** + * A class for making DOM elements draggable (including touch support). + * Used internally for map and marker dragging. Only works for elements + * that were positioned with [`L.DomUtil.setPosition`](#domutil-setposition). + */ + export class Draggable extends Evented { + constructor(element: HTMLElement, dragStartTarget?: HTMLElement, preventOutline?: boolean); + + enable(): void; + + disable(): void; + + finishDrag(): void; + } + interface LayerOptions { pane?: string; } @@ -475,6 +490,15 @@ declare namespace L { bringToFront(): this; bringToBack(): this; setUrl(url: string): this; + + /** Update the bounds that this ImageOverlay covers */ + setBounds(bounds: LatLngBounds): this; + + /** Get the bounds that this ImageOverlay covers */ + getBounds(): LatLngBounds; + + /** Get the img element that represents the ImageOverlay on the map */ + getElement(): HTMLImageElement; } export function imageOverlay(imageUrl: string, bounds: LatLngBoundsExpression, options?: ImageOverlayOptions): ImageOverlay; diff --git a/leaflet/leaflet-tests.ts b/leaflet/leaflet-tests.ts index 34a5fa245f..47776a75ac 100644 --- a/leaflet/leaflet-tests.ts +++ b/leaflet/leaflet-tests.ts @@ -326,3 +326,9 @@ map = map .remove() .whenReady(() => {}) .whenReady(() => {}, {}); + +let elementToDrag = document.createElement('div'); +let draggable = new L.Draggable(elementToDrag); +draggable.enable(); +draggable.disable(); +draggable.on('drag', () => {}); \ No newline at end of file