ReferenceScripting APIDragComponent
DragComponent
classLets the pointer drag its mote: pressed on it, the mote follows the pointer until let go.
| Name | DragComponent |
|---|---|
| Kind | class |
| Script reaches it as | import { DragComponent } from "motion" |
| Since | 0.4 |
Syntax
class DragComponent extends Component { … }Properties
| Name | Type | Description |
|---|---|---|
nameproperty | readonly string | Its name on its mote. |
layerproperty | readonly string | Its layer's id. |
visibleproperty | boolean | Whether its layer shows. |
opacityproperty | number | Its layer's opacity, 0 to 1. |
moteproperty | readonly Mote | null | Its mote. |
axisproperty | "" | "x" | "y" | "x" or "y" to drag along one way alone; "" both. |
enabledproperty | boolean | Whether it drags. |
draggingproperty | readonly boolean | Whether it's being dragged now. |
Methods
| Signature | Description |
|---|---|
set(key: string, value: SettingValue): voidmethod | Changes one of its layer's settings. |
animate(key: string, value: string | number, seconds: number, options?: MotionAnimateOptions): Promise<boolean>method | Moves one of its layer's settings. |
stopAnimating(key?: string): voidmethod | Stops its layer's moves. |
get(key: string): SettingValue | undefinedmethod | One of its layer's settings, as scene.get. |
read(key: string): SettingValue | undefinedmethod | One of its layer's settings as last drawn, as scene.read. |
show(visible?: boolean): voidmethod | Shows (or hides) its layer. |
hide(): voidmethod | Hides its layer. |
new DragComponent(name: string, mote: Mote, options?: { axis?: "x" | "y" }): DragComponentconstructor | Makes a mote draggable with the pointer. |
See also
Notes from the community
Written by creators and checked by the docs' editors. Not part of Motion's official reference.