Draggable

Class Draggable

A draggable and droppable HTML element.

Extends EventTarget

constructor ($el: ElementView, options: DraggableOptions): Draggable

Name Type Default Description
$el ElementView    
options DraggableOptions  

readonly Property .$el : ElementView

Property .disabled : boolean

Default value: false

Property .options : DraggableOptions

Property .position : Point

Default value: ...

Property .startPos : Point

Default value: ...

Method .addTarget ($target: ElementView): void

Name Type Default Description
$target ElementView    

Method .checkTarget (posn: Point): void

Name Type Default Description
posn Point    

Method .off (events: string, fn: EventCallback): void

Removes an event listener from one or more events.

Name Type Default Description
events string    
fn EventCallback    

Method .on (events: string, fn: EventCallback): void

Adds an event listener for one or more events.

Name Type Default Description
events string    
fn EventCallback    

Method .one (events: string, fn: EventCallback): void

Adds a one-time event listener to one or more events.

Name Type Default Description
events string    
fn EventCallback    

Method .removeTarget ($target: ElementView): void

Name Type Default Description
$target ElementView    

Method .resetPosition (duration: number): Promise<void>

Name Type Default Description
duration number 250  

Method .setPosition (x: number, y: number): void

Sets the position of the element.

Name Type Default Description
x number    
y number    

Method .trigger (events: string, arg: unknown): void

Triggers one or more events, and executes all bound event listeners.

Name Type Default Description
events string    
arg unknown    

Method .updateBounds (): undefined|Bounds


Copyright © 2024 Mathigon.org