-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuseIsMobile.d.ts
More file actions
47 lines (44 loc) · 1.35 KB
/
Copy pathuseIsMobile.d.ts
File metadata and controls
47 lines (44 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/**
* Options for useIsMobile hook
*/
interface UseIsMobileOptions {
/**
* Debounce time in milliseconds for resize events (default: 0)
*/
debounce?: number;
/**
* Enable screen orientation detection (default: false)
* When enabled, returns an object with isMobile and orientation
*/
enableOrientation?: boolean;
}
/**
* Result when enableOrientation is true
*/
interface UseIsMobileWithOrientation {
isMobile: boolean;
orientation: 'portrait' | 'landscape';
}
/**
* Detects if the current viewport is mobile based on a max-width media query.
* @param mobileScreenSize - Maximum screen width in pixels to consider as mobile (default: 768)
* @param options - Additional options for debounce and orientation detection
* @returns boolean if orientation disabled, object with isMobile and orientation if enabled
* @example
* // Basic usage
* const isMobile = useIsMobile(); // default threshold: 768px
*
* // Custom threshold
* const isTablet = useIsMobile(1024); // custom threshold: 1024px
*
* // With debounce
* const isMobile = useIsMobile(768, { debounce: 100 });
*
* // With orientation
* const { isMobile, orientation } = useIsMobile(768, { enableOrientation: true });
*/
declare function useIsMobile(
mobileScreenSize?: number,
options?: UseIsMobileOptions
): boolean | UseIsMobileWithOrientation;
export default useIsMobile;