Types
Complete TypeScript type definitions for VistaView.
Core Types
Section titled “Core Types”VistaParams
Section titled “VistaParams”Main configuration interface including the elements property.
interface VistaParams extends VistaOpt { elements: string | VistaImgConfig[];}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.
interface VistaOpt { // Animation animationDurationBase?: number;
// Zoom maxZoomLevel?: number;
// Preloading preloads?: number;
// Interaction keyboardListeners?: boolean; arrowOnSmallScreens?: boolean; rapidLimit?: number;
// Styling initialZIndex?: number;
// Controls controls?: { topLeft?: (VistaDefaultCtrl | string)[]; topRight?: (VistaDefaultCtrl | string)[]; topCenter?: (VistaDefaultCtrl | string)[]; bottomCenter?: (VistaDefaultCtrl | string)[]; bottomLeft?: (VistaDefaultCtrl | string)[]; bottomRight?: (VistaDefaultCtrl | string)[]; };
// Extensions extensions?: VistaExtension[];
// Event Callbacks onOpen?: (vistaView:` [VistaView](/api-reference/classes/vistaview)) => void; onClose?: (vistaView:` [VistaView](/api-reference/classes/vistaview)) => void; onImageView?: (data:` [VistaData](#vistadata), vistaView: [VistaView](/api-reference/classes/vistaview)) => void; onContentChange?: (content:` [VistaImageClone](#vistaimageclone), vistaView: [VistaView](/api-reference/classes/vistaview)) => void;
// Lifecycle Functions initFunction?: VistaInitFn; imageSetupFunction?: VistaImageSetupFn; transitionFunction?: VistaTransitionFn; openFunction?: VistaOpenFn; closeFunction?: VistaCloseFn;}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().
interface VistaInterface { open(index?: number): void; close(): Promise<void>; view(index: number): void; next(): void; prev(): void; reset(): void; zoomIn(): void; zoomOut(): void; getCurrentIndex(): number; destroy(): void;}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()- Reset zoom and positionzoomIn()- Zoom inzoomOut()- Zoom outgetCurrentIndex()- Get current image indexdestroy()- Destroy instance and cleanup
VistaImgConfig
Section titled “VistaImgConfig”Image configuration object.
interface VistaImgConfig { src: string; alt?: string; srcSet?: string;}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.
interface VistaData { htmlElements: { from: HTMLElement[] | null; to: HTMLElement[] | null; }; images: { from: VistaBox[] | null; to: VistaBox[] | null; }; index: { from: number | null; to: number | null; }; via: { next: boolean; prev: boolean; };}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.
interface VistaImageClone { config: { src: string; alt?: string; srcSet?: string; }; origin: { src: string; srcSet: string; borderRadius: string; objectFit: string; } | null; parsedSrcSet?: { src: string; width: number }[]; element: string; thumb?: string; index: number; pos: number; state: { width: number; height: number; transform: { x: number; y: number; scale: number; }; translate: { x: number; y: number; }; };}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.
interface VistaParsedElm { config: VistaImgConfig; parsedSrcSet?: { src: string; width: number }[]; origin?: VistaImgOrigin;}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.
interface VistaImgOrigin { anchor?: HTMLAnchorElement; image: HTMLImageElement; src: string; srcSet: string; borderRadius: string; objectFit: string;}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.
type VistaInitFn = (vistaView: VistaView) => void;Parameters:
vistaView:VistaView - The VistaView instance
VistaImageSetupFn
Section titled “VistaImageSetupFn”Type for custom setup function when navigating between images.
type VistaImageSetupFn = (data: VistaData, vistaView: VistaView) => void;Parameters:
VistaTransitionFn
Section titled “VistaTransitionFn”Type for custom transition animation function.
type VistaTransitionFn = ( data: VistaData, abortSignal: AbortSignal, vistaView: VistaView) => { cleanup: () => void; transitionEnded: Promise<void> } | void;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.
type VistaOpenFn = (vistaView: VistaView) => void;Parameters:
vistaView:VistaView - The VistaView instance
VistaCloseFn
Section titled “VistaCloseFn”Type for custom close function.
type VistaCloseFn = (vistaView: VistaView) => void;Parameters:
vistaView:VistaView - The VistaView instance
Extension Types
Section titled “Extension Types”VistaExtension
Section titled “VistaExtension”Interface for creating extensions.
interface VistaExtension { name: string; description?: string; control?: () => HTMLElement | null; onInitializeImage?: (parsed: VistaImageParams) => VistaBox | void | null | undefined; onImageView?: (data:` [VistaData](#vistadata), vistaView: [VistaView](/api-reference/classes/vistaview)) => void; onContentChange?: (content:` [VistaImageClone](#vistaimageclone), vistaView: [VistaView](/api-reference/classes/vistaview)) => void; onDeactivateUi?: (names: string[], requestBy:` [VistaBox](#vistabox) | null, vistaView: [VistaView](/api-reference/classes/vistaview)) => void; onReactivateUi?: (names: string[], requestBy:` [VistaBox](#vistabox) | null, vistaView: [VistaView](/api-reference/classes/vistaview)) => void; onOpen?: (vistaView:` [VistaView](/api-reference/classes/vistaview)) => void; onClose?: (vistaView:` [VistaView](/api-reference/classes/vistaview)) => void;}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.
type VistaDefaultCtrl = 'indexDisplay' | 'zoomIn' | 'zoomOut' | 'close' | 'description';Advanced Types
Section titled “Advanced Types”VistaImageParams
Section titled “VistaImageParams”Parameters passed to extension onInitializeImage hook.
interface VistaImageParams { elm: VistaParsedElm; pos: number; index: number; maxZoomLevel: number; onScale: (par: { vistaImage: VistaBox; scale: number; isMax: boolean; isMin: boolean }) => void; vistaView: VistaView; transitionState?: VistaHiresTransitionOpt; transitionShouldWait?: () => boolean;}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.
type VistaPointer = { x: number; y: number; movementX: number; movementY: number; id: number | string;};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
VistaExternalPointerListenerArgs
Section titled “VistaExternalPointerListenerArgs”Arguments passed to external pointer listeners registered via registerPointerListener().
type VistaExternalPointerListenerArgs = { event: 'down' | 'move' | 'up' | 'cancel'; pointer: VistaPointer; pointers: VistaPointer[]; lastPointerLen: number; state: VistaState; hasInternalExecution: boolean; abortController: AbortController | null;};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