Skip to main content

Callbacks

CallbackWhenCancel
onClick(event)single click on a part, 200 ms after release (at once when double click is off)yes
onDoubleClick(event)second click within 350 msyes
onHome(event)home buttonyes
onDragStart(event), onDrag(event), onDragEnd(event)drag past 6 px, each move, releaseonDrag and onDragEnd cancel their view change
onViewChange(target, reason)the default action of every gesture; reason is click, double-click, drag, drag-end, home or keyboard
onFit(reason)when the action includes a fit
onHover(part)the part under the pointer changes (null when none)

Cancelling​

Call event.preventDefault() on the event a gesture callback receives; return values are ignored. The event carries part, target and pointerType (mouse, pen, touch or keyboard).

<ViewCube
orientation={view}
onClick={(event) => {
if (event.part?.kind === 'corner') event.preventDefault();
}}
onViewChange={go}
/>

The target​

ViewTarget has kind, partId, part, pitch, yaw (on the shortest path from from), from, direction (world vector from the scene toward the camera), up (world), quaternion (camera world rotation in the given convention), fit, and transition { kind, duration, easing }.