DragActivity

Drag activity: how many drags are active, and which element holds each axis. While a drag is active no hover and no press starts, as Motion's; and a drag that claims an axis another element holds is refused, so a nested drag on the same axis doesn't move both. A drag counts in once it's past its threshold, and counts off at its end or when it's interrupted. DragRecognizer's drags keep it; a recognizer of your own reads it, or counts in and claims as a drag does.

By default every runtime shares one, as Motion's is shared; a runtime can provide its own, as the test Environment does, so tests stay apart. It's synchronous, so a fold reads it inline.

import * as DragActivity from "@wardic/core/DragActivity"

const activity = yield* DragActivity.DragActivity
const release = activity.claim(card, "x") // None when another element holds x
activity.isDragActive() // true until it's released

Interfaces

Shape

The active drags and the axes they hold: what DragActivity gives.

Properties

claim
readonly claim: (target, axis) => Option<() => void>;

Claims axis for target (both axes for "xy") and counts one more active drag. None when another target holds one of those axes: the drag is refused, and nothing is counted or claimed. Otherwise its release, which counts it off and gives up its axes, once, however often it's called. A target's own claims share its hold, which ends at the last one's release.

Parameters
target

unknown

axis

Axis

Returns

Option<() => void>

count
readonly count: () => () => void;

Counts one more active drag that claims no axis (claim: false). Its release counts it off, once.

Returns

() => void

isDragActive
readonly isDragActive: () => boolean;

Whether any drag is active.

Returns

boolean

Variables

DragActivity

const DragActivity: Context.Reference<Shape>;

The runtime's Drag activity: one shared by every runtime unless a runtime provides its own.

Functions

make()

function make(): Shape;

A fresh Drag activity, with no drag active and no axis held: for a runtime that provides its own.

Returns

Shape