uix-image-magnify 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ImageMagnify-zNjM2jVN.d.cts +90 -0
- package/dist/ImageMagnify-zNjM2jVN.d.ts +90 -0
- package/dist/index.cjs +648 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +88 -62
- package/dist/index.d.ts +88 -62
- package/dist/index.js +648 -81
- package/dist/index.js.map +1 -1
- package/dist/ssr/index.cjs +294 -80
- package/dist/ssr/index.cjs.map +1 -1
- package/dist/ssr/index.d.cts +2 -2
- package/dist/ssr/index.d.ts +2 -2
- package/dist/ssr/index.js +295 -81
- package/dist/ssr/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CSSProperties, ImgHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ZoomType = "hover" | "click" | "double-click" | "hold" | "wheel" | "none";
|
|
5
|
+
type PanePosition = "left" | "right" | "top" | "bottom";
|
|
6
|
+
type LensShape = "circle" | "square";
|
|
7
|
+
type MagnifyMode = "lens" | "side-by-side" | "inner" | "follow";
|
|
8
|
+
type DragMode = "follow" | "pan";
|
|
9
|
+
interface UseImageMagnifyOptions {
|
|
10
|
+
/** Base image URL (required when used standalone). */
|
|
11
|
+
src?: string;
|
|
12
|
+
/** High-resolution image used for the zoomed view. Defaults to `src`. */
|
|
13
|
+
zoomSrc?: string;
|
|
14
|
+
/** Magnification factor (2 = 200%). */
|
|
15
|
+
zoomScale?: number;
|
|
16
|
+
/** Minimum scale for wheel/keyboard zoom. Default `1.5`. */
|
|
17
|
+
minZoomScale?: number;
|
|
18
|
+
/** Maximum scale for wheel/keyboard zoom. Default `5`. */
|
|
19
|
+
maxZoomScale?: number;
|
|
20
|
+
/** Interaction that activates zoom. */
|
|
21
|
+
zoomType?: ZoomType;
|
|
22
|
+
/** How the zoomed content is displayed. */
|
|
23
|
+
mode?: MagnifyMode;
|
|
24
|
+
/** Drag interaction for `inner` mode. */
|
|
25
|
+
dragMode?: DragMode;
|
|
26
|
+
/** Where the side-by-side pane sits relative to the image. */
|
|
27
|
+
panePosition?: PanePosition;
|
|
28
|
+
/** Diameter / side length of the lens in px. */
|
|
29
|
+
lensSize?: number;
|
|
30
|
+
/** Lens shape. */
|
|
31
|
+
lensShape?: LensShape;
|
|
32
|
+
/** Offset (both axes, px) for `mode="follow"`. */
|
|
33
|
+
followOffset?: number;
|
|
34
|
+
/** Disable all interaction. */
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/** Preload the high-res image to avoid a flash. */
|
|
37
|
+
zoomPreload?: boolean;
|
|
38
|
+
/** Reset zoom when the pointer leaves the container. */
|
|
39
|
+
resetOnLeave?: boolean;
|
|
40
|
+
onZoomStart?: () => void;
|
|
41
|
+
onZoomEnd?: () => void;
|
|
42
|
+
onZoomChange?: (scale: number) => void;
|
|
43
|
+
}
|
|
44
|
+
declare function useImageMagnify(options?: UseImageMagnifyOptions): {
|
|
45
|
+
isZoomed: boolean;
|
|
46
|
+
zoomScale: number;
|
|
47
|
+
bgImage: string | undefined;
|
|
48
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
49
|
+
imageRef: React.RefObject<HTMLImageElement>;
|
|
50
|
+
lensRef: React.RefObject<HTMLDivElement>;
|
|
51
|
+
paneRef: React.RefObject<HTMLDivElement>;
|
|
52
|
+
cursorRef: React.RefObject<HTMLDivElement>;
|
|
53
|
+
handlers: {
|
|
54
|
+
onPointerEnter: (e: React.PointerEvent) => void;
|
|
55
|
+
onPointerLeave: (e: React.PointerEvent) => void;
|
|
56
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
|
57
|
+
onPointerMove: (e: React.PointerEvent) => void;
|
|
58
|
+
onPointerUp: (e: React.PointerEvent) => void;
|
|
59
|
+
onPointerCancel: () => void;
|
|
60
|
+
onDoubleClick: (e: React.MouseEvent) => void;
|
|
61
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
62
|
+
onFocus: () => void;
|
|
63
|
+
onBlur: () => void;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface ImageMagnifyProps extends UseImageMagnifyOptions {
|
|
68
|
+
src: string;
|
|
69
|
+
alt: string;
|
|
70
|
+
/** Rendered width of the image (height follows aspect ratio). */
|
|
71
|
+
width?: number | string;
|
|
72
|
+
className?: string;
|
|
73
|
+
style?: CSSProperties;
|
|
74
|
+
imageClassName?: string;
|
|
75
|
+
imageStyle?: CSSProperties;
|
|
76
|
+
lensClassName?: string;
|
|
77
|
+
lensStyle?: CSSProperties;
|
|
78
|
+
paneClassName?: string;
|
|
79
|
+
paneStyle?: CSSProperties;
|
|
80
|
+
paneWidth?: number;
|
|
81
|
+
paneHeight?: number;
|
|
82
|
+
lazy?: boolean;
|
|
83
|
+
/** Extra attributes forwarded to the underlying <img>. */
|
|
84
|
+
imageProps?: Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt" | "style">;
|
|
85
|
+
onLoad?: ImgHTMLAttributes<HTMLImageElement>["onLoad"];
|
|
86
|
+
onError?: ImgHTMLAttributes<HTMLImageElement>["onError"];
|
|
87
|
+
}
|
|
88
|
+
declare const ImageMagnify: React.ForwardRefExoticComponent<ImageMagnifyProps & React.RefAttributes<HTMLDivElement>>;
|
|
89
|
+
|
|
90
|
+
export { type DragMode as D, type ImageMagnifyProps as I, type LensShape as L, type MagnifyMode as M, type PanePosition as P, type UseImageMagnifyOptions as U, type ZoomType as Z, ImageMagnify as a, useImageMagnify as u };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CSSProperties, ImgHTMLAttributes } from 'react';
|
|
3
|
+
|
|
4
|
+
type ZoomType = "hover" | "click" | "double-click" | "hold" | "wheel" | "none";
|
|
5
|
+
type PanePosition = "left" | "right" | "top" | "bottom";
|
|
6
|
+
type LensShape = "circle" | "square";
|
|
7
|
+
type MagnifyMode = "lens" | "side-by-side" | "inner" | "follow";
|
|
8
|
+
type DragMode = "follow" | "pan";
|
|
9
|
+
interface UseImageMagnifyOptions {
|
|
10
|
+
/** Base image URL (required when used standalone). */
|
|
11
|
+
src?: string;
|
|
12
|
+
/** High-resolution image used for the zoomed view. Defaults to `src`. */
|
|
13
|
+
zoomSrc?: string;
|
|
14
|
+
/** Magnification factor (2 = 200%). */
|
|
15
|
+
zoomScale?: number;
|
|
16
|
+
/** Minimum scale for wheel/keyboard zoom. Default `1.5`. */
|
|
17
|
+
minZoomScale?: number;
|
|
18
|
+
/** Maximum scale for wheel/keyboard zoom. Default `5`. */
|
|
19
|
+
maxZoomScale?: number;
|
|
20
|
+
/** Interaction that activates zoom. */
|
|
21
|
+
zoomType?: ZoomType;
|
|
22
|
+
/** How the zoomed content is displayed. */
|
|
23
|
+
mode?: MagnifyMode;
|
|
24
|
+
/** Drag interaction for `inner` mode. */
|
|
25
|
+
dragMode?: DragMode;
|
|
26
|
+
/** Where the side-by-side pane sits relative to the image. */
|
|
27
|
+
panePosition?: PanePosition;
|
|
28
|
+
/** Diameter / side length of the lens in px. */
|
|
29
|
+
lensSize?: number;
|
|
30
|
+
/** Lens shape. */
|
|
31
|
+
lensShape?: LensShape;
|
|
32
|
+
/** Offset (both axes, px) for `mode="follow"`. */
|
|
33
|
+
followOffset?: number;
|
|
34
|
+
/** Disable all interaction. */
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
/** Preload the high-res image to avoid a flash. */
|
|
37
|
+
zoomPreload?: boolean;
|
|
38
|
+
/** Reset zoom when the pointer leaves the container. */
|
|
39
|
+
resetOnLeave?: boolean;
|
|
40
|
+
onZoomStart?: () => void;
|
|
41
|
+
onZoomEnd?: () => void;
|
|
42
|
+
onZoomChange?: (scale: number) => void;
|
|
43
|
+
}
|
|
44
|
+
declare function useImageMagnify(options?: UseImageMagnifyOptions): {
|
|
45
|
+
isZoomed: boolean;
|
|
46
|
+
zoomScale: number;
|
|
47
|
+
bgImage: string | undefined;
|
|
48
|
+
containerRef: React.RefObject<HTMLDivElement>;
|
|
49
|
+
imageRef: React.RefObject<HTMLImageElement>;
|
|
50
|
+
lensRef: React.RefObject<HTMLDivElement>;
|
|
51
|
+
paneRef: React.RefObject<HTMLDivElement>;
|
|
52
|
+
cursorRef: React.RefObject<HTMLDivElement>;
|
|
53
|
+
handlers: {
|
|
54
|
+
onPointerEnter: (e: React.PointerEvent) => void;
|
|
55
|
+
onPointerLeave: (e: React.PointerEvent) => void;
|
|
56
|
+
onPointerDown: (e: React.PointerEvent) => void;
|
|
57
|
+
onPointerMove: (e: React.PointerEvent) => void;
|
|
58
|
+
onPointerUp: (e: React.PointerEvent) => void;
|
|
59
|
+
onPointerCancel: () => void;
|
|
60
|
+
onDoubleClick: (e: React.MouseEvent) => void;
|
|
61
|
+
onKeyDown: (e: React.KeyboardEvent) => void;
|
|
62
|
+
onFocus: () => void;
|
|
63
|
+
onBlur: () => void;
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
interface ImageMagnifyProps extends UseImageMagnifyOptions {
|
|
68
|
+
src: string;
|
|
69
|
+
alt: string;
|
|
70
|
+
/** Rendered width of the image (height follows aspect ratio). */
|
|
71
|
+
width?: number | string;
|
|
72
|
+
className?: string;
|
|
73
|
+
style?: CSSProperties;
|
|
74
|
+
imageClassName?: string;
|
|
75
|
+
imageStyle?: CSSProperties;
|
|
76
|
+
lensClassName?: string;
|
|
77
|
+
lensStyle?: CSSProperties;
|
|
78
|
+
paneClassName?: string;
|
|
79
|
+
paneStyle?: CSSProperties;
|
|
80
|
+
paneWidth?: number;
|
|
81
|
+
paneHeight?: number;
|
|
82
|
+
lazy?: boolean;
|
|
83
|
+
/** Extra attributes forwarded to the underlying <img>. */
|
|
84
|
+
imageProps?: Omit<ImgHTMLAttributes<HTMLImageElement>, "src" | "alt" | "style">;
|
|
85
|
+
onLoad?: ImgHTMLAttributes<HTMLImageElement>["onLoad"];
|
|
86
|
+
onError?: ImgHTMLAttributes<HTMLImageElement>["onError"];
|
|
87
|
+
}
|
|
88
|
+
declare const ImageMagnify: React.ForwardRefExoticComponent<ImageMagnifyProps & React.RefAttributes<HTMLDivElement>>;
|
|
89
|
+
|
|
90
|
+
export { type DragMode as D, type ImageMagnifyProps as I, type LensShape as L, type MagnifyMode as M, type PanePosition as P, type UseImageMagnifyOptions as U, type ZoomType as Z, ImageMagnify as a, useImageMagnify as u };
|