メインコンテンツまでスキップ

Function: elementMapping()

function elementMapping(getElement, __namedParameters?): DragValueMapping;

Defined in: dom/src/pointer/drag-value.ts:61

Map the pointer onto the bounding rect of an element: the value is the position pointed at, so the middle of the element is 0.5.

The element is read on every event, so it may be mounted after the drag is set up and may change size while a drag is in progress.

Parameters​

ParameterTypeDescription
getElement() => Element | null | undefined-
__namedParameters{ sensitivity?: (state) => number; }-
__namedParameters.sensitivity?(state) => numberHow much the movement counts, read on every move. 1 is the pointer position itself; 0.1 makes the same movement cover a tenth of the travel, which is what a fine-adjustment modifier wants. Anything but 1 turns the mapping relative: the value stops being the position pointed at and starts being where it stood when the sensitivity changed, plus the movement since. The pointer and the value stay apart for the rest of the drag rather than snapping back together when the key is released, since snapping would move the value nobody asked to move.

Returns​

DragValueMapping