VistaPointers Class
The VistaPointers class provides a unified interface for tracking mouse and touch pointer events. It normalizes pointer data across different input types and manages multi-touch gestures.
Overview
Section titled “Overview”VistaPointers handles:
- Mouse, touch, and pen input tracking
- Multi-pointer gestures (pinch, pan)
- Pointer movement calculations
- Event normalization across input types
Use Case: Primarily used internally by VistaView for handling interactions. Extensions can access pointer data through event listeners.
Public Properties
Section titled “Public Properties”None - all properties are private.
Public Methods
Section titled “Public Methods”constructor()
Section titled “constructor()”Creates a new pointer tracking system.
Parameters:
args.elm- Element to attach listeners to (defaults todocument)args.listeners- Array of pointer listeners
Example:
startListeners()
Section titled “startListeners()”Starts listening to pointer events. Called automatically by constructor.
removeListeners()
Section titled “removeListeners()”Removes all pointer event listeners. Call this when cleaning up.
Example:
addEventListener()
Section titled “addEventListener()”Adds a pointer event listener.
Example:
removeEventListener()
Section titled “removeEventListener()”Removes a specific pointer event listener.
getPointerDistance()
Section titled “getPointerDistance()”Calculates the distance between two pointers. Useful for pinch-to-zoom gestures.
Parameters:
Returns: Distance in pixels
Example:
getCentroid()
Section titled “getCentroid()”Calculates the center point of all active pointers. Returns null if no pointers are active.
Returns: Center coordinates or null
Example:
Related
Section titled “Related”- VistaPointer - Pointer data type
- VistaPointerListener - Listener function type
- VistaExternalPointerListenerArgs - Event arguments