Callbacks
| Callback | When | Cancel |
|---|---|---|
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 ms | yes |
onHome(event) | home button | yes |
onDragStart(event), onDrag(event), onDragEnd(event) | drag past 6 px, each move, release | onDrag 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 }.