Motion
Get Motion

ReferenceScripting APIDragComponent

DragComponent

class

Lets the pointer drag its mote: pressed on it, the mote follows the pointer until let go.

NameDragComponent
Kindclass
Script reaches it asimport { DragComponent } from "motion"
Since0.4

Syntax

class DragComponent extends Component { … }

Properties

NameTypeDescription
namepropertyreadonly stringIts name on its mote.
layerpropertyreadonly stringIts layer's id.
visiblepropertybooleanWhether its layer shows.
opacitypropertynumberIts layer's opacity, 0 to 1.
motepropertyreadonly Mote | nullIts mote.
axisproperty"" | "x" | "y""x" or "y" to drag along one way alone; "" both.
enabledpropertybooleanWhether it drags.
draggingpropertyreadonly booleanWhether it's being dragged now.

Methods

SignatureDescription
set(key: string, value: SettingValue): voidmethodChanges one of its layer's settings.
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>methodMoves one of its layer's settings.
stopAnimating(key?: string): voidmethodStops its layer's moves.
get(key: string): SettingValue | undefinedmethodOne of its layer's settings, as scene.get.
read(key: string): SettingValue | undefinedmethodOne of its layer's settings as last drawn, as scene.read.
show(visible?: boolean): voidmethodShows (or hides) its layer.
hide(): voidmethodHides its layer.
new DragComponent(name: string, mote: Mote, options?: { axis?: "x" | "y" }): DragComponentconstructorMakes a mote draggable with the pointer.

See also

SettingValue · Mote