UNPKG

react-native-gesture-image-viewer

Version:

🖼️ A highly customizable and easy-to-use React Native image viewer with gesture support and external controls

50 lines 2.13 kB
import type { GestureViewerEventCallback, GestureViewerEventType } from './types'; /** * Hook for subscribing to GestureViewer events on the default instance. * * This hook allows you to listen to specific events from the default GestureViewer instance * (with ID 'default'), such as zoom changes or rotation changes. Events are automatically * throttled to prevent excessive callback invocations during gestures. * * @param eventType - The type of event to listen for * @param callback - Function to call when the event occurs * * @example * ```tsx * // Listen to zoom changes on the default instance (ID: 'default') * useGestureViewerEvent('zoomChange', (data) => { * console.log(`Zoom changed from ${data.previousScale} to ${data.scale}`); * }); * * // Listen to rotation changes on the default instance (ID: 'default') * useGestureViewerEvent('rotationChange', (data) => { * console.log(`Rotation changed from ${data.previousRotation}° to ${data.rotation}°`); * }); * ``` */ export declare function useGestureViewerEvent<T extends GestureViewerEventType>(eventType: T, callback: GestureViewerEventCallback<T>): void; /** * Hook for subscribing to GestureViewer events with a specific instance ID. * * Use this overload when you have multiple GestureViewer instances and need * to listen to events from a specific one. * * @param id - The unique identifier of the GestureViewer instance * @param eventType - The type of event to listen for * @param callback - Function to call when the event occurs * * @example * ```tsx * // Listen to zoom changes on a specific instance * useGestureViewerEvent('gallery', 'zoomChange', (data) => { * console.log(`Gallery zoom: ${data.scale}x`); * }); * * // Listen to rotation changes on a modal viewer * useGestureViewerEvent('modal-viewer', 'rotationChange', (data) => { * updateRotationIndicator(data.rotation); * }); * ``` */ export declare function useGestureViewerEvent<T extends GestureViewerEventType>(id: string, eventType: T, callback: GestureViewerEventCallback<T>): void; //# sourceMappingURL=useGestureViewerEvent.d.ts.map