Types
Complete TypeScript type definitions for VistaView.
Core Types
Section titled “Core Types”VistaParams
Section titled “VistaParams”Main configuration interface including the elements property.
Properties:
elements(required): CSS selector string or array of VistaImgConfig configurations- Extends VistaOpt with all configuration options
VistaOpt
Section titled “VistaOpt”Base configuration options interface.
Related Types:
- VistaDefaultCtrl - Control names
- VistaExtension - Extension system
- VistaData, VistaImageClone - Event data
- VistaInitFn, VistaImageSetupFn, VistaTransitionFn, VistaOpenFn, VistaCloseFn - Lifecycle functions
VistaInterface
Section titled “VistaInterface”Instance interface with control methods returned by vistaView().
Methods:
open(index?)- Opens lightbox at specified indexclose()- Closes lightbox (returns Promise)view(index)- Navigate to specific imagenext()- Navigate to next imageprev()- Navigate to previous imagereset()- Recalculate elements and re-attach event listeners (useful after DOM changes)zoomIn()- Zoom inzoomOut()- Zoom outgetCurrentIndex()- Get current image indexdestroy()- Destroy instance and cleanup
VistaImgConfig
Section titled “VistaImgConfig”Image configuration object.
Properties:
src(required): Image URLalt(optional): Alt text for accessibilitysrcSet(optional): Responsive image sources
Event Data Types
Section titled “Event Data Types”VistaData
Section titled “VistaData”Data passed to event callbacks and transition functions.
Properties:
htmlElements.from- Previous HTML elementshtmlElements.to- New HTML elementsimages.from- Previous image objectsimages.to- New image objectsindex.from- Previous image index (null on initial open)index.to- New image indexvia.next- True if navigated via nextvia.prev- True if navigated via previous
VistaImageClone
Section titled “VistaImageClone”Current image state passed to onContentChange callback.
Properties:
config- Image configuration (src, alt, srcSet)origin- Original element properties (null for non-image content)parsedSrcSet- Parsed srcSet attributeelement- HTML string of the contentthumb- Thumbnail URL (if applicable)index- Current image indexpos- Position in the viewstate.width- Current widthstate.height- Current heightstate.transform- Transform state (x, y, scale)state.translate- Translation offsets (x, y)
VistaParsedElm
Section titled “VistaParsedElm”Parsed element information passed to extensions.
Properties:
config- Image configuration (VistaImgConfig)parsedSrcSet- Parsed srcSet attribute with sources and widthsorigin- Origin element properties (VistaImgOrigin)
VistaImgOrigin
Section titled “VistaImgOrigin”Origin element properties for animations.
Properties:
anchor- The original anchor element (if exists)image- The original image elementsrc- Original image sourcesrcSet- Original srcSet attributeborderRadius- Original border radius styleobjectFit- Original object-fit style
Lifecycle Function Types
Section titled “Lifecycle Function Types”VistaInitFn
Section titled “VistaInitFn”Type for custom initialization function.
Parameters:
vistaView:VistaView - The VistaView instance
VistaImageSetupFn
Section titled “VistaImageSetupFn”Type for custom setup function when navigating between images.
Parameters:
VistaTransitionFn
Section titled “VistaTransitionFn”Type for custom transition animation function.
Parameters:
data:VistaData - Navigation dataabortSignal: AbortSignal- Signal to abort the transitionvistaView:VistaView - The VistaView instance
Returns: Object with cleanup function and promise, or void
VistaOpenFn
Section titled “VistaOpenFn”Type for custom open function.
Parameters:
vistaView:VistaView - The VistaView instance
VistaCloseFn
Section titled “VistaCloseFn”Type for custom close function.
Parameters:
vistaView:VistaView - The VistaView instance
Extension Types
Section titled “Extension Types”VistaExtension
Section titled “VistaExtension”Interface for creating extensions.
Properties:
name(required) - Unique identifier for the extensiondescription(optional) - Human-readable descriptioncontrol(optional) - Returns a custom UI control elementonInitializeImage(optional) - Hook to replace default image creationonImageView(optional) - Triggered when navigating between imagesonContentChange(optional) - Triggered when content changesonDeactivateUi(optional) - Triggered when UI controls are deactivatedonReactivateUi(optional) - Triggered when UI controls are reactivatedonOpen(optional) - Triggered when lightbox opensonClose(optional) - Triggered when lightbox closes
Type References:
- VistaImageParams - Used in
onInitializeImage - VistaData - Used in
onImageView - VistaImageClone - Used in
onContentChange
Control Types
Section titled “Control Types”VistaDefaultCtrl
Section titled “VistaDefaultCtrl”Built-in control names.
Advanced Types
Section titled “Advanced Types”VistaImageParams
Section titled “VistaImageParams”Parameters passed to extension onInitializeImage hook.
Properties:
elm- Parsed element (VistaParsedElm)pos- Position in the viewindex- Image indexmaxZoomLevel- Maximum zoom levelonScale- Callback for scale changesvistaView- VistaView instancetransitionState- Optional transition statetransitionShouldWait- Optional transition wait function
Pointer Event Types
Section titled “Pointer Event Types”VistaPointer
Section titled “VistaPointer”Represents a single pointer (mouse, touch, or pen) position and movement.
Properties:
x- Current X coordinatey- Current Y coordinatemovementX- Movement delta on X axis since last eventmovementY- Movement delta on Y axis since last eventid- Unique identifier for this pointer
VistaPointerListenerArgs
Section titled “VistaPointerListenerArgs”Arguments passed to internal pointer listeners used by VistaPointers.
Properties:
event- Type of pointer eventpointer- Current VistaPointer datapointers- Array of all active VistaPointer instanceslastPointerLen- Previous number of active pointers (for detecting pointer count changes)
VistaPointerListener
Section titled “VistaPointerListener”A listener function passed to VistaPointers via VistaPointerArgs.listeners or addEventListener().
Parameters:
args- VistaPointerListenerArgs event data
VistaExternalPointerListenerArgs
Section titled “VistaExternalPointerListenerArgs”Arguments passed to external pointer listeners registered via registerPointerListener().
Properties:
event- Type of pointer eventpointer- Current VistaPointer datapointers- Array of all active VistaPointer instanceslastPointerLen- Previous number of pointers (for detecting changes)state- VistaState instancehasInternalExecution- Whether VistaView handled this event internallyabortController- Controller for canceling operations