import { UseViewportPositionReturn, ViewportInfo, ViewportPosition, VisibilityState } from '../types';
/**
* Hook to track an element's position relative to the viewport.
*
* @remarks
* This hook provides comprehensive information about an element's
* position in the viewport, including visibility state, intersection
* ratio, and distance from viewport edges.
*
* @returns Viewport position information and utilities
*
* @example
* ```tsx
* function MyComponent() {
* const {
* position,
* isVisible,
* isFullyVisible,
* visibility,
* ref,
* scrollIntoView,
* } = useViewportPosition();
*
* return (
*
* {isVisible && I'm visible! }
* {!isFullyVisible && (
* scrollIntoView()}>
* Scroll into view
*
* )}
*
* );
* }
* ```
*/
export declare function useViewportPosition(): UseViewportPositionReturn;
/**
* Hook to track visibility state only (optimized for performance).
*
* @returns Visibility state
*
* @example
* ```tsx
* function LazyImage({ src }: { src: string }) {
* const { isVisible, ref } = useVisibility();
*
* return (
*
* {isVisible ?
:
}
*
* );
* }
* ```
*/
export declare function useVisibility(): {
isVisible: boolean;
isFullyVisible: boolean;
visibility: VisibilityState;
ref: {
readonly current: HTMLElement | null;
};
};
/**
* Hook to get intersection ratio with the viewport.
*
* @returns Intersection ratio (0-1) and ref
*
* @example
* ```tsx
* function AnimatedElement() {
* const { ratio, ref } = useIntersectionRatio();
*
* return (
*
* Animated content
*
* );
* }
* ```
*/
export declare function useIntersectionRatio(): {
ratio: number;
ref: {
readonly current: HTMLElement | null;
};
};
/**
* Hook to track distance from viewport edges.
*
* @returns Distance object and ref
*
* @example
* ```tsx
* function DistanceDisplay() {
* const { distance, ref } = useDistanceFromViewport();
*
* return (
*
* Top: {distance?.top}px, Bottom: {distance?.bottom}px
*
* );
* }
* ```
*/
export declare function useDistanceFromViewport(): {
distance: ViewportPosition['distanceFromViewport'] | null;
ref: {
readonly current: HTMLElement | null;
};
};
/**
* Hook to track distance from viewport center.
*
* @returns Distance from center and ref
*
* @example
* ```tsx
* function CenterFocusedElement() {
* const { distanceFromCenter, ref } = useDistanceFromCenter();
*
* // Scale based on proximity to center
* const scale = Math.max(0.5, 1 - (distanceFromCenter / 500) * 0.5);
*
* return (
*
* Focus me!
*
* );
* }
* ```
*/
export declare function useDistanceFromCenter(): {
distanceFromCenter: number;
ref: {
readonly current: HTMLElement | null;
};
};
/**
* Hook to get current viewport information.
*
* @returns Viewport info
*
* @example
* ```tsx
* function ViewportDisplay() {
* const viewport = useViewport();
*
* return (
*
* {viewport.width}x{viewport.height}
* {viewport.orientation === 'portrait' && ' (Portrait)'}
*
* );
* }
* ```
*/
export declare function useViewport(): ViewportInfo;
/**
* Hook to get viewport dimensions.
*
* @returns Viewport width and height
*
* @example
* ```tsx
* function ResponsiveComponent() {
* const { width, height } = useViewportDimensions();
*
* if (width < 768) {
* return ;
* }
*
* return ;
* }
* ```
*/
export declare function useViewportDimensions(): {
width: number;
height: number;
};
/**
* Hook to get viewport scroll position.
*
* @returns Scroll x and y positions
*
* @example
* ```tsx
* function ScrollProgress() {
* const { scrollY } = useViewportScroll();
* const viewport = useViewport();
*
* const progress = scrollY / (viewport.scrollHeight - viewport.height);
*
* return ;
* }
* ```
*/
export declare function useViewportScroll(): {
scrollX: number;
scrollY: number;
};
/**
* Hook to check if on a touch device.
*
* @returns Whether device supports touch
*
* @example
* ```tsx
* function InteractiveElement() {
* const isTouch = useIsTouch();
*
* return (
*
* Interact with me
*
* );
* }
* ```
*/
export declare function useIsTouch(): boolean;
/**
* Hook to get device orientation.
*
* @returns Current orientation
*
* @example
* ```tsx
* function OrientationAware() {
* const orientation = useOrientation();
*
* return (
*
* Current: {orientation}
*
* );
* }
* ```
*/
export declare function useOrientation(): 'portrait' | 'landscape';
/**
* Hook to get safe area insets.
*
* @returns Safe area insets
*
* @example
* ```tsx
* function SafeContainer({ children }) {
* const safeArea = useSafeAreaInsets();
*
* return (
*
* {children}
*
* );
* }
* ```
*/
export declare function useSafeAreaInsets(): ViewportInfo['safeAreaInsets'];