⚠ Early release: v0.3.2.sophistry is not ready for production use. Until 1.0, any minor release may break the API; expect missing features and bugs too.Stability and versioning
Interaction
Interaction in sophistry writes to the same tracks that animations drive. A draggable (or useMovablePoint) updates a track, constraints (onCircle, snapToGrid, toBounds) shape where it may go, and every prop bound to that track, directly or through derive, follows it. Nodes also take event props (onClick, onDrag, …). Every draggable is also a keyboard-focusable tab stop, so these scenes work without a pointer.
Start with Dragging and input (DragConstraints, then KeyboardAccessible). Cameras, zoom and drill-down moves the view instead of the scene.
Dragging and input
Draggables, constraints, keyboard access, sliders, drop targets and scroll.
- First scene: make it draggableStep three of the first-scene tutorial: the same theta track that the animation writes is now also written by dragging the dot around the ring.
- Drag constraintsThree dots with three rules: one moves freely, one is pinned to a circle, and one snaps to a grid of 0.5 units.
- Drag along a ringA dot constrained to a circle, draggable with the pointer or the arrow keys.
- Keyboard-accessible draggingEvery draggable is also a tab stop. Tab to the dot, then use the arrow keys to move it by 0.5 units (hold Shift for 0.1), or Escape to cancel a drag in progress.
- A slider that drives a graphDrag the knob along a line to change the frequency of a sine wave. scalarParam turns the pointer position into a number, and the graph reads that number.
- Linked dotsDrag any corner of the triangle. The outline and the area readout are derived from the three dragged points, so they update on every move.
- Drop targetsDrag the token onto either box. Each box lights up while the token is over it, and the choice is reported when you let go.
- Step-through lessonDrag the token onto the right answer to unlock Next. Wrong drops bounce back; Tab to a box and press Enter to answer without a pointer.
- Scroll-driven animationScroll the box: its scroll position is the timeline's time. A sticky stage stays pinned while the page behind it moves, and scrolling back rewinds the scene.
Cameras, zoom and drill-down
Pan and zoom, camera flights, inset views, chart zoom and hierarchy drill-down.
- Pan and zoomScroll to zoom about the cursor and drag empty space to pan. PanZoom writes the same units and center tracks that the Stage reads.
- Animating the cameraA stage's units and center are ordinary tracks, so moveTo and valueTo fly the camera between landmarks. Nothing is rebuilt: the same scene repaints through a new view.
- Picture-in-pictureOne scene seen through two cameras. Drag the dot in the main view and the magnified inset follows it.
- Zoom a chart with the wheel, a pinch or the keysScroll over the top chart to zoom about the cursor, drag it to pan, pinch on a touch screen, or Tab to it and use + and -, the arrows, and 0 to reset. The zoom writes two tracks and the overview's brush reads the same two, so it follows the zoom, and dragging the brush moves it.
- Drag a box to zoomDrag a rectangle over the plot to zoom into it (a thin one zooms one axis), hold Shift to pan instead, Backspace to step back out, and 0 or a double tap to reset; Escape mid-drag cancels. The toolbar in the corner switches between panning and box zoom and resets, and each button is a tab stop. The x axis is logarithmic: zooms and the bounds work in decades. The wheel over the plot zooms the chart, and anywhere else it zooms the stage's own PanZoom camera.
- Zooming a category axisThe top chart is a window onto twelve of thirty-six months. Scroll over it to zoom, drag to pan, or Tab to it and use the arrows and + and -: drags, pinches and keys settle on whole months, and the names leaving the window fade. The overview's brush reads the same two tracks; scroll over the brush to grow or shrink it.
- Tap to drill into a treemapTap a tile to zoom into its folder, tap a crumb above to zoom back out; Tab and Enter do the same. The zoom is a tween of the chart's focus, so it is exactly the scrubbable drill-down transition, and under reduced motion it dissolves instead.
- Tap to zoom into a treeTap a node to spread its subtree over the chart, tap it again (or the back arrow, or a crumb) to zoom out; Tab and Enter do the same. Deep trails collapse their middle into an ellipsis that climbs back up.
- Zoomable circle packingTap a circle to zoom into it and the background to zoom out, along d3's smooth zoom path. The chart is controlled: createDrillDown holds the focus and tweens it, and the same focus drives the breadcrumb trail, so both scrub together.