UI Events — ui-events.js
ui-events.js handles zoom controls, redaction box resizing/dragging, and thumbnail rendering.
Zoom
updateZoomLevelText()
Syncs the zoom input display with state.currentZoom.
updateCSSZoom()
Applies the current zoom by setting the --scale-factor CSS custom property on the viewer. Also calls onZoomChange() if defined (used by the text tool to update Fabric canvas dimensions).
processZoomFromText(newZoom, mouseX?, mouseY?)
Constrains the zoom to [minZoom, maxZoom], updates state.currentZoom, and applies. When mouse coordinates are provided (Ctrl+Wheel), preserves the document position under the cursor by adjusting scroll offsets.
Zoom is CSS-only — no canvas re-rendering is needed because pages are <img> elements that scale via CSS transforms.
Redaction Resizing
initResize(e, idx, edge)
Called when a user drags one of the four edge handles (l, r, t, b):
- Captures start position and dimensions
- On
mousemove: updatesr.x/r.y/r.width/r.heightbased on drag delta, scaled by1/currentZoom - Updates overlay CSS custom properties in real-time
- Re-evaluates matches for the affected redaction (live)
- Updates the match summary count
- On
mouseup: removes listeners
Redaction Dragging
initDragRedaction(e, idx)
Called on mousedown on a redaction overlay (not on a resizer or label):
- Captures start position
- On
mousemove: updatesr.xandr.ybased on delta, scaled by1/currentZoom - Moves the overlay via CSS custom properties
- On
mouseup: removes listeners
Thumbnails
renderThumbnails()
Builds the sidebar thumbnail strip from state.pageImages. Each thumbnail is a 180px-wide <img> with a page number label. Clicking navigates to that page via goToPage(). The active page gets the .active class.