interface RVG · Visuals

RvgHandle

interface RvgHandle extends RvgPin, Pin

A point the user can drag with the pointer.

A handle is a pin drawn as a disk. While the user drags it, every pointer move writes the pointer position (in the coordinates of the handle's group) into the handle as one update. Code reacts to it with Reactive.do([handle], …) or uses the handle as the target of Attach. Code can move a handle too, by writing its x and y.

To keep a handle on a path or inside an area, write the allowed position back into the handle in its own reaction, for example Circles.closestPoint(circle, handle, handle). The reaction does not run again because of its own write.

Several draggable things that show one value: draw them as plain visuals and use one hidden handle (CSS visibility: hidden). On pointerdown on one of the visuals, set handle.active.value = true; the handle then follows the pointer until it is released. In the handle's reaction, return while active is false and turn the handle's position into the value; the value never writes into the handle. With one handle per thing, each moves the others, and the dragged one jumps between the pointer and the computed position.

Properties

activereadonly

active: Bool

True while the user drags the handle.

It turns true when the pointer is pressed on the handle and false when it is released, also outside the graphic. Moves made by code do not change it, so a reaction can tell them apart from a drag. Setting it to true starts a drag: the handle follows the pointer until it is released.

isInteractive

isInteractive: boolean

Whether the user can start a drag by pressing on the handle (default: true). With false, code can still move the handle.

Inherited

From Pin dx, dy

From RvgVisual applyStyleDirective, fromGraphic, getVisualBoundingBox, mounted, toGraphic, visible, zIndex

From RvgPoint radius

From Vector x, y