Luxar Viewer API Documentation - v2026.9.22
    Preparing search index...

    Class DimensionSliders

    Interactive UI component providing sliders for navigating through non-displayed dimensions.

    This component creates a sophisticated slider interface that allows users to navigate through nD datasets by adjusting positions in dimensions not currently displayed in 3D. It provides both mouse and keyboard interaction with visual feedback and status display.

    Key features:

    • Custom-styled sliders with progress bars and thumb indicators
    • Automatic handling of discrete vs continuous dimensions
    • Real-time synchronization with the scene dimension manager
    • Keyboard navigation with fine/coarse stepping
    • Status bar showing current slice position
    • Responsive layout that adapts to available screen space

    Design philosophy:

    • Mimics napari-style slider aesthetics for scientific familiarity
    • Only shows sliders for non-displayed dimensions to avoid confusion
    • Provides immediate visual feedback during navigation
    • Handles edge cases gracefully (empty slices, discrete quantization)

    Slider synchronization:

    1. User moves slider → triggers sceneDimsManager.setDimensionValue()
    2. sceneDimsManager notifies all listeners → triggers update()
    3. update() refreshes slider visuals and status display
    4. Points re-slice automatically via their own listeners

    DimensionSliders

    Index
    • Create and initialize the dimension slider UI component.

      Builds the complete slider interface including styled containers, individual sliders for each non-displayed dimension, and status bar showing current slice positions. The UI follows napari-style aesthetics for scientific data visualization familiarity.

      The sliders are automatically synchronized with sceneDimsManager - moving a slider triggers dimension changes which update all nD objects in the scene.

      Parameters

      • config: SliderConfig

        Configuration object for slider initialization

        Configuration interface for initializing dimension sliders.

        SliderConfig

        • container: HTMLElement

          DOM container where slider UI will be mounted

        • dims: SimpleDims

          Current dimension state from scene manager

        • dimensionRanges: [number, number][]

          Navigable bounds for each dimension

        • dimensionNames: string[]

          Human-readable names for each dimension

        • OptionaldimensionUnits?: string[]

          Optional physical units for each dimension

        • OptionalselectedDimension?: number

          Zero-based position in the non-displayed dimension list selected for [ / ].

        • OptionalonSelectDimension?: (navigableIndex: number) => void

          Fired when the panel selects the [ / ] target itself: under a coarse pointer each dimension's name is a tappable chip, the finger's stand-in for the 1–9 keys. Receives the position in the non-displayed list.

      Returns DimensionSliders

      // After scene loads and dims are initialized
      const dims = sceneDimsManager.getDims();
      const ranges = sceneDimsManager.getDimensionRanges();
      const names = sceneDimsManager.getDimensionNames();

      const sliders = new DimensionSliders({
      container: getViewerContainer(),
      dims,
      dimensionRanges: ranges,
      dimensionNames: names,
      dimensionUnits: ['μm', 'μm', 'μm', 's', '']
      });

      // Sliders now appear at bottom of viewport
      // User can drag sliders or use arrow keys to navigate
    container: HTMLElement

    Root DOM container for the slider UI

    slidersContainer: HTMLElement

    Glass-surface root of the panel (positioning, sizing, visibility)

    scrollBody: HTMLElement

    Inner scroll wrapper that holds all panel content. Scrolling must not live on the glass root (its glass layers paint at inset: 0 behind it and a scroll container clips them) — see UI_DESIGN_GUIDE §5.1.2/§7.4. Created once, so clearing the content never destroys it.

    statusText: HTMLElement | null = null

    Status text element in the title bar

    Current dimension state (reference to scene manager state)

    dimensionRanges: [number, number][]

    Navigable bounds for each dimension

    dimensionNames: string[]

    Human-readable dimension names for UI labeling

    dimensionUnits: string[]

    Physical units for each dimension

    selectedDimension: number

    Zero-based position in the non-displayed dimension list selected for [ / ].

    onSelectDimension?: (navigableIndex: number) => void
    sliders: Map<number, HTMLInputElement> = ...

    Map of dimension indices to their corresponding HTML slider elements

    dropdowns: Map<number, HTMLSelectElement> = ...

    Map of dimension indices to their corresponding dropdown select elements

    toggles: Map<number, HTMLElement> = ...

    Map of dimension indices to their corresponding toggle elements (binary categoricals)

    sliderEvents: EventGroup = ...

    Cleanup group for all per-slider DOM listeners (input, keydown, change, toggle click, play-button click + contextmenu). The group is rebuilt on every createSliders() call so that disposing it removes every listener from the previous render in one shot — no per-handler bookkeeping.

    Hover/focus visual states are handled entirely by CSS :hover and :focus pseudo-classes — no JS listeners are attached for those.

    animationManager?: DimensionAnimationManager

    Animation manager for dimension playback (set by InputHandler)

    playButtons: Map<number, HTMLButtonElement> = ...

    Map of dimension indices to play button elements

    sliderElements: Map<
        number,
        { valueLabel: HTMLElement; progressBar: HTMLElement; thumb: HTMLElement },
    > = ...

    Cached DOM refs for the per-slider visual children. Filled in createSlider, read by updateSliderVisuals to avoid three document.getElementById lookups per call (this method runs at up to 60 fps during animation playback).

    activeContextMenu: HTMLElement | null = null

    Active context menu element (only one can be open at a time)

    contextMenuCleanup: {
        clickOutside?: (e: MouseEvent) => void;
        clickOutsideTimeout?: Timeout;
    } = {}

    Stored event handlers for context menu cleanup

    Type Declaration

    • OptionalclickOutside?: (e: MouseEvent) => void
    • OptionalclickOutsideTimeout?: Timeout

      Pending setTimeout that will install the click-outside handler. Tracked so closeContextMenu() can cancel it if the menu is closed before the deferred handler is attached — without this, the listener gets attached but never removed, leaking on every Escape-cancel.

    animationManagerEvents: EventGroup = ...

    Cleanup group for animation-manager listeners. Rebuilt every time setAnimationManager() is called so that re-binding to a new manager (or detaching from the old one) is a single dispose.

    • Private

      Create the main container element for sliders with napari-style styling.

      Builds a fixed-position panel at bottom-center of viewport with:

      • Semi-transparent dark background with blur
      • Rounded corners and subtle shadow
      • Responsive width (80% of viewport, max 800px, min 400px)
      • Scroll support if many dimensions, delegated to an inner wrapper so the glass root can stay overflow: visible (§5.1.2/§7.4)

      Returns { root: HTMLElement; scroll: HTMLElement }

      The glass root and the inner scroll wrapper that receives content

    • Private

      Creates individual slider controls for all non-displayed dimensions.

      This method rebuilds the entire slider interface, creating a separate control for each dimension that isn't currently being displayed in the 3D scene. The logic ensures that users only see controls for dimensions they can actually navigate through.

      UI structure:

      • Title header with visual separator
      • Individual sliders for each non-displayed dimension
      • Fallback message if all dimensions are displayed

      Returns void

    • Private

      Create a dropdown control optimized for grid layout.

      Compact dropdown designed to fit in a responsive grid (max 3 per row). Used for categorical dimensions with < 10 categories.

      Provides:

      • Compact layout with dimension name prefix
      • Category labels in dropdown options
      • Keyboard navigation (arrow keys, [ / ] keys)
      • Cyclic wrapping if dimension.cyclic = true
      • Tooltips matching Luxar UI style

      Parameters

      • dimIndex: number

        Zero-based index of dimension to create dropdown for

      • gridContainer: HTMLElement

        Grid container to append dropdown to

      Returns void

    • Private

      Create a binary toggle control for a dimension with exactly 2 values.

      Segmented toggle button that shows both labels side by side with the active value highlighted. Single click toggles between the two values.

      Provides:

      • Compact segmented layout: [ValueA | ValueB]
      • One-click toggle interaction (vs 2-click dropdown)
      • Keyboard navigation (arrow keys, [ / ] keys, Space, Enter)
      • Tooltips matching Luxar UI style

      Parameters

      • dimIndex: number

        Zero-based index of dimension to create toggle for

      • gridContainer: HTMLElement

        Grid container to append toggle to

      Returns void

    • Private

      Update a toggle element's text and visual state.

      Shows the current value's label. When value is 1 (second option), applies the --on modifier for highlighted styling.

      Parameters

      • toggle: HTMLElement

        The toggle button element

      • activeValue: number

        The currently active value (0 or 1)

      Returns void

    • Private

      Create an individual slider control for a specific dimension.

      Builds a complete slider UI with:

      • Dimension name label and current value display
      • Custom-styled range input with visual progress bar
      • Animated thumb indicator
      • Keyboard navigation support (arrow keys with Shift for fine control)

      Handles both discrete (frame-based) and continuous (time-based) dimensions with appropriate step sizes and value formatting. For categorical dimensions with many categories (≥10), displays category labels.

      Parameters

      • dimIndex: number

        Zero-based index of dimension to create slider for

      Returns void

    • Coarse pointers only: ‹ track ›, one dimension step per tap (the authored step, else 1 % of the range — the same base step as the [ / ] keys), in the same wrapper the play button later joins. A finger cannot scroll a slider by a single step, and a phone has no bracket keys; the buttons are the missing precise input.

      Parameters

      • dimIndex: number
      • name: string
      • sliderContainer: HTMLElement

      Returns HTMLElement

    • Coarse pointers only: the dimension's name selects it as the [ / ] target.

      Parameters

      • dimIndex: number
      • dimName: HTMLElement

      Returns void

    • Private

      Update visual elements of a slider to reflect current value.

      Synchronizes all visual components:

      • Value label text (formatted with units, or category label for categorical dimensions)
      • Progress bar width (fraction of full range)
      • Thumb position (aligned with progress bar)
      • Tooltip with detailed information

      Called during slider creation and whenever dimension value changes (from keyboard navigation or programmatic updates).

      Parameters

      • dimIndex: number

        Dimension index to update visuals for

      • value: number

        Current dimension value to display

      • isDiscrete: boolean

        If true, rounds value to integer for display

      Returns void

    • Toggle dimension sliders visibility on/off.

      Switches between visible and hidden states. Triggered by N key. Does not destroy the sliders - they remain in DOM but hidden.

      Returns void

      // User presses 'N' key
      dimensionSliders.toggle();
      // Sliders disappear if visible, appear if hidden
    • Get current visibility state of sliders.

      Returns boolean

      true if sliders are currently visible, false if hidden

    • Hide the dimension sliders panel.

      Sets display to 'none'. Sliders remain in DOM for fast re-showing. Use when temporarily hiding UI or when dataset has no non-displayed dimensions.

      Returns void

    • Updates the status bar text to reflect the current dimensional state.

      The status bar shows the current keyboard-navigation target and the dimensions displayed in 3D. Per-dimension values remain visible on their own controls.

      Format:

      • Available target: "[/]: 1 · Channel · Display: X, Y, Z"
      • No target: "[/]: unavailable · Display: X, Y, Z"

      Returns void

    • Update the dimension targeted by the global [ / ] keyboard shortcuts.

      Parameters

      • selectedDimension: number

      Returns void

    • Synchronizes all controls (sliders and dropdowns) with the current dimension state.

      This method is called by the scene dimension manager's observer system whenever dimensions change. It ensures the UI accurately reflects the current slice positions by updating control positions, value labels, and the status bar.

      Critical for maintaining UI consistency during:

      • Keyboard navigation
      • Programmatic dimension changes
      • Camera centering operations that adjust displayed dimension positions

      Returns void

    • Private

      Add animation controls to a specific slider (compact layout with context menu)

      Parameters

      • dimIndex: number
      • sliderGroup: HTMLElement

      Returns void

    • Private

      Show context menu for animation settings (Napari-style)

      Parameters

      • dimIndex: number
      • x: number
      • y: number

      Returns void

    • Private

      Update play button appearance based on animation state

      Parameters

      • dimIndex: number
      • isPlaying: boolean

      Returns void

    • Set visibility of slider interface (show or hide).

      Used by main application to control slider display based on dataset characteristics (nD vs 3D) or user preferences.

      Parameters

      • visible: boolean

        true to show sliders, false to hide them

      Returns void

      // Show sliders only if dataset has non-displayed dimensions
      const hasNonDisplayed = sceneDimsManager.hasNonDisplayedDimensions();
      dimensionSliders.setVisible(hasNonDisplayed);
    • Clean up slider UI and release resources.

      Removes all DOM elements and clears internal state. Important for preventing memory leaks when visualization is destroyed or reinitialized with different dataset.

      After calling dispose(), the DimensionSliders instance cannot be reused. Create a new instance if sliders are needed again.

      Returns void

      // Before loading new scene
      dimensionSliders.dispose();
      dimensionSliders = null;

      // After new scene loads
      dimensionSliders = new DimensionSliders(newConfig);