VistaState Class
The VistaState class manages the internal state of a VistaView instance. It tracks the current state of the lightbox, including open/close status, current image, zoom level, and registered extensions.
Overview
Section titled “Overview”VistaState is automatically instantiated by VistaView and accessible via the state property. It provides a centralized location for all runtime state information.
Access:
Properties
Section titled “Properties”Whether the lightbox is currently open. true when the lightbox is visible, false when closed.
settled
Section titled “settled”Whether the open transition animation has completed. Useful for determining if the lightbox is fully settled after opening.
closing
Section titled “closing”Whether the lightbox is currently in the process of closing. true during the close transition animation.
zoomedIn
Section titled “zoomedIn”Whether the current image is zoomed beyond its minimum scale. false when the image is at fit-to-viewport scale, true when zoomed in.
children
Section titled “children”Current DOM elements and image instances in the view.
Properties:
htmls- Array of HTML container elements (.vvw-itemdivs)images- Array of VistaBox instances (images or custom content)
The arrays include the current image plus preloaded images based on the preloads configuration option.
Example:
currentIndex
Section titled “currentIndex”Zero-based index of the currently displayed image. -1 when the lightbox is closed.
Example:
elmLength
Section titled “elmLength”Total number of images in the gallery. Updated automatically when reset() is called.
Example:
abortController
Section titled “abortController”Controller for canceling in-progress transitions. Automatically reset before each navigation to abort the previous transition.
Use Case: Extensions can listen to the abort signal to cancel long-running operations when the user navigates quickly.
Example:
isReducedMotion
Section titled “isReducedMotion”Whether the user has requested reduced motion via system preferences. Detected from the prefers-reduced-motion media query.
Example:
extensions
Section titled “extensions”Set of registered extension instances. Populated from the extensions configuration option.
Example:
Related
Section titled “Related”- VistaView Class - Main controller class that uses VistaState
- VistaExtension - Extension interface type
- Extensions - Extension system documentation