ng-images-preview 1.0.3 → 2.0.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/README.md +43 -5
- package/fesm2022/ng-images-preview.mjs +682 -192
- package/fesm2022/ng-images-preview.mjs.map +1 -1
- package/package.json +1 -1
- package/types/ng-images-preview.d.ts +163 -13
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
2
|
import { TemplateRef, ElementRef, OnDestroy } from '@angular/core';
|
|
3
|
+
import { SafeHtml } from '@angular/platform-browser';
|
|
4
|
+
|
|
5
|
+
declare const PREVIEW_ICONS: {
|
|
6
|
+
close: string;
|
|
7
|
+
prev: string;
|
|
8
|
+
next: string;
|
|
9
|
+
flipH: string;
|
|
10
|
+
flipV: string;
|
|
11
|
+
rotateLeft: string;
|
|
12
|
+
rotateRight: string;
|
|
13
|
+
zoomOut: string;
|
|
14
|
+
zoomIn: string;
|
|
15
|
+
};
|
|
3
16
|
|
|
4
17
|
interface ImagesPreviewState {
|
|
5
18
|
src: string;
|
|
@@ -20,19 +33,89 @@ interface ImagesPreviewActions {
|
|
|
20
33
|
reset: () => void;
|
|
21
34
|
close: () => void;
|
|
22
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Configuration for the toolbar.
|
|
38
|
+
*/
|
|
39
|
+
interface ToolbarConfig {
|
|
40
|
+
showZoom?: boolean;
|
|
41
|
+
showRotate?: boolean;
|
|
42
|
+
showFlip?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Context passed to the custom template.
|
|
46
|
+
*/
|
|
47
|
+
interface ImagesPreviewContext {
|
|
48
|
+
$implicit: ImagesPreviewState;
|
|
49
|
+
actions: ImagesPreviewActions;
|
|
50
|
+
}
|
|
51
|
+
interface ImageBufferItem {
|
|
52
|
+
src: string;
|
|
53
|
+
index: number;
|
|
54
|
+
offset: number;
|
|
55
|
+
srcset?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Image Preview Overlay Component.
|
|
59
|
+
* Displays images in a full-screen overlay with zoom, rotate, and pan capabilities.
|
|
60
|
+
*/
|
|
23
61
|
declare class ImagesPreviewComponent {
|
|
62
|
+
/**
|
|
63
|
+
* The image source to display.
|
|
64
|
+
* @required
|
|
65
|
+
*/
|
|
24
66
|
src: _angular_core.InputSignal<string>;
|
|
67
|
+
/**
|
|
68
|
+
* List of image URLs for gallery navigation.
|
|
69
|
+
*/
|
|
25
70
|
images: _angular_core.InputSignal<string[] | undefined>;
|
|
71
|
+
/**
|
|
72
|
+
* Optional srcset for the single image `src`.
|
|
73
|
+
*/
|
|
74
|
+
srcset: _angular_core.InputSignal<string | undefined>;
|
|
75
|
+
/**
|
|
76
|
+
* List of srcsets corresponding to the `images` array.
|
|
77
|
+
* Must be 1:1 mapped with `images`.
|
|
78
|
+
*/
|
|
79
|
+
srcsets: _angular_core.InputSignal<string[] | undefined>;
|
|
80
|
+
/**
|
|
81
|
+
* Initial index for gallery navigation.
|
|
82
|
+
* @default 0
|
|
83
|
+
*/
|
|
26
84
|
initialIndex: _angular_core.InputSignal<number>;
|
|
27
|
-
|
|
85
|
+
/**
|
|
86
|
+
* DOMRect of the element that opened the preview.
|
|
87
|
+
* Used for FLIP animation calculation.
|
|
88
|
+
*/
|
|
89
|
+
openerRect: _angular_core.InputSignal<DOMRect | undefined>;
|
|
90
|
+
/**
|
|
91
|
+
* Custom template to render instead of the default viewer.
|
|
92
|
+
* Exposes `ImagesPreviewContext`.
|
|
93
|
+
*/
|
|
94
|
+
customTemplate: _angular_core.InputSignal<TemplateRef<ImagesPreviewContext> | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Configuration for the toolbar buttons.
|
|
97
|
+
*/
|
|
98
|
+
toolbarConfig: _angular_core.InputSignal<ToolbarConfig>;
|
|
99
|
+
/**
|
|
100
|
+
* Callback function called when the preview is closed.
|
|
101
|
+
*/
|
|
28
102
|
closeCallback: () => void;
|
|
29
|
-
|
|
103
|
+
imgRefs: _angular_core.Signal<readonly ElementRef<HTMLImageElement>[]>;
|
|
104
|
+
thumbRefs: _angular_core.Signal<readonly ElementRef<HTMLElement>[]>;
|
|
30
105
|
currentIndex: _angular_core.WritableSignal<number>;
|
|
31
|
-
isLoading: _angular_core.WritableSignal<boolean>;
|
|
32
106
|
hasError: _angular_core.WritableSignal<boolean>;
|
|
33
|
-
|
|
107
|
+
loadedImages: _angular_core.WritableSignal<Set<string>>;
|
|
108
|
+
showThumbnails: _angular_core.InputSignal<boolean>;
|
|
109
|
+
showToolbar: _angular_core.InputSignal<boolean>;
|
|
110
|
+
toolbarExtensions: _angular_core.InputSignal<TemplateRef<any> | null>;
|
|
111
|
+
activeBuffer: _angular_core.Signal<ImageBufferItem[]>;
|
|
34
112
|
private platformId;
|
|
113
|
+
private sanitizer;
|
|
114
|
+
icons: {
|
|
115
|
+
[key in keyof typeof PREVIEW_ICONS]: SafeHtml;
|
|
116
|
+
};
|
|
35
117
|
constructor();
|
|
118
|
+
private flipAnimDone;
|
|
36
119
|
scale: _angular_core.WritableSignal<number>;
|
|
37
120
|
translateX: _angular_core.WritableSignal<number>;
|
|
38
121
|
translateY: _angular_core.WritableSignal<number>;
|
|
@@ -40,9 +123,10 @@ declare class ImagesPreviewComponent {
|
|
|
40
123
|
flipH: _angular_core.WritableSignal<boolean>;
|
|
41
124
|
flipV: _angular_core.WritableSignal<boolean>;
|
|
42
125
|
isDragging: _angular_core.WritableSignal<boolean>;
|
|
126
|
+
isInertia: _angular_core.WritableSignal<boolean>;
|
|
43
127
|
private initialPinchDistance;
|
|
44
128
|
private initialScale;
|
|
45
|
-
|
|
129
|
+
isPinching: _angular_core.WritableSignal<boolean>;
|
|
46
130
|
state: _angular_core.Signal<ImagesPreviewState>;
|
|
47
131
|
actions: ImagesPreviewActions;
|
|
48
132
|
private readonly MIN_SCALE;
|
|
@@ -61,7 +145,11 @@ declare class ImagesPreviewComponent {
|
|
|
61
145
|
private readonly FRICTION;
|
|
62
146
|
private readonly VELOCITY_THRESHOLD;
|
|
63
147
|
private readonly MAX_VELOCITY;
|
|
64
|
-
|
|
148
|
+
getTransform(offset: number): string;
|
|
149
|
+
private flipTransform;
|
|
150
|
+
private getCurrentImageElement;
|
|
151
|
+
private runFlipAnimation;
|
|
152
|
+
overlayBackground: _angular_core.Signal<string>;
|
|
65
153
|
onEscape(): void;
|
|
66
154
|
onMouseMove(event: MouseEvent): void;
|
|
67
155
|
private applyMoveConstraints;
|
|
@@ -78,10 +166,14 @@ declare class ImagesPreviewComponent {
|
|
|
78
166
|
onTouchEnd(event: TouchEvent): void;
|
|
79
167
|
private lastTouchX;
|
|
80
168
|
private lastTouchY;
|
|
169
|
+
private initialPinchCenter;
|
|
170
|
+
private initialTranslateX;
|
|
171
|
+
private initialTranslateY;
|
|
81
172
|
private getDistance;
|
|
173
|
+
private getCenter;
|
|
82
174
|
close(): void;
|
|
83
|
-
onImageLoad(): void;
|
|
84
|
-
onImageError(): void;
|
|
175
|
+
onImageLoad(src: string): void;
|
|
176
|
+
onImageError(src: string): void;
|
|
85
177
|
zoomIn(): void;
|
|
86
178
|
zoomOut(): void;
|
|
87
179
|
rotateLeft(): void;
|
|
@@ -91,16 +183,68 @@ declare class ImagesPreviewComponent {
|
|
|
91
183
|
reset(): void;
|
|
92
184
|
next(): void;
|
|
93
185
|
prev(): void;
|
|
186
|
+
jumpTo(index: number): void;
|
|
187
|
+
private animateSlide;
|
|
94
188
|
onMouseDown(event: MouseEvent): void;
|
|
95
189
|
onTouchStart(event: TouchEvent): void;
|
|
96
190
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ImagesPreviewComponent, never>;
|
|
97
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ImagesPreviewComponent, "ng-images-preview", never, { "src": { "alias": "src"; "required": true; "isSignal": true; }; "images": { "alias": "images"; "required": false; "isSignal": true; }; "initialIndex": { "alias": "initialIndex"; "required": false; "isSignal": true; }; "customTemplate": { "alias": "customTemplate"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
191
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<ImagesPreviewComponent, "ng-images-preview", never, { "src": { "alias": "src"; "required": true; "isSignal": true; }; "images": { "alias": "images"; "required": false; "isSignal": true; }; "srcset": { "alias": "srcset"; "required": false; "isSignal": true; }; "srcsets": { "alias": "srcsets"; "required": false; "isSignal": true; }; "initialIndex": { "alias": "initialIndex"; "required": false; "isSignal": true; }; "openerRect": { "alias": "openerRect"; "required": false; "isSignal": true; }; "customTemplate": { "alias": "customTemplate"; "required": false; "isSignal": true; }; "toolbarConfig": { "alias": "toolbarConfig"; "required": false; "isSignal": true; }; "showThumbnails": { "alias": "showThumbnails"; "required": false; "isSignal": true; }; "showToolbar": { "alias": "showToolbar"; "required": false; "isSignal": true; }; "toolbarExtensions": { "alias": "toolbarExtensions"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
|
|
98
192
|
}
|
|
99
193
|
|
|
194
|
+
/**
|
|
195
|
+
* Directive to open the image preview.
|
|
196
|
+
* Can be used on any element, but auto-detects `src` on `img` or nested `img`.
|
|
197
|
+
*/
|
|
100
198
|
declare class ImagesPreviewDirective implements OnDestroy {
|
|
199
|
+
/**
|
|
200
|
+
* High resolution image source to display in preview.
|
|
201
|
+
* If empty, tries to read `src` from host element or first child `img`.
|
|
202
|
+
*/
|
|
101
203
|
highResSrc: string;
|
|
204
|
+
/**
|
|
205
|
+
* List of images for gallery navigation.
|
|
206
|
+
* If provided, enables previous/next navigation buttons.
|
|
207
|
+
*/
|
|
102
208
|
previewImages: string[];
|
|
103
|
-
|
|
209
|
+
/**
|
|
210
|
+
* Custom template to use for the preview.
|
|
211
|
+
* If provided, overrides the default viewer UI.
|
|
212
|
+
*/
|
|
213
|
+
previewTemplate?: TemplateRef<ImagesPreviewContext>;
|
|
214
|
+
/**
|
|
215
|
+
* Configuration for the toolbar buttons.
|
|
216
|
+
*/
|
|
217
|
+
toolbarConfig?: ToolbarConfig;
|
|
218
|
+
/**
|
|
219
|
+
* Optional srcset for the single image.
|
|
220
|
+
*/
|
|
221
|
+
srcset?: string;
|
|
222
|
+
/**
|
|
223
|
+
* List of srcsets corresponding to the `previewImages` array.
|
|
224
|
+
*/
|
|
225
|
+
/**
|
|
226
|
+
* List of srcsets corresponding to the `previewImages` array.
|
|
227
|
+
*/
|
|
228
|
+
srcsets?: string[];
|
|
229
|
+
/**
|
|
230
|
+
* Whether to show the thumbnail strip.
|
|
231
|
+
* @default true
|
|
232
|
+
*/
|
|
233
|
+
showThumbnails: boolean;
|
|
234
|
+
/**
|
|
235
|
+
* Whether to show the toolbar.
|
|
236
|
+
* @default true
|
|
237
|
+
*/
|
|
238
|
+
showToolbar: boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Custom template to render in the toolbar (e.g. for download buttons).
|
|
241
|
+
*/
|
|
242
|
+
toolbarExtensions: TemplateRef<any> | null;
|
|
243
|
+
/**
|
|
244
|
+
* Type guard helper for strict template type checking.
|
|
245
|
+
* Allows Angular Language Service to infer types in `previewTemplate`.
|
|
246
|
+
*/
|
|
247
|
+
static ngTemplateContextGuard(directive: ImagesPreviewDirective, context: unknown): context is ImagesPreviewContext;
|
|
104
248
|
private componentRef;
|
|
105
249
|
private appRef;
|
|
106
250
|
private injector;
|
|
@@ -112,8 +256,14 @@ declare class ImagesPreviewDirective implements OnDestroy {
|
|
|
112
256
|
private destroyPreview;
|
|
113
257
|
ngOnDestroy(): void;
|
|
114
258
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<ImagesPreviewDirective, never>;
|
|
115
|
-
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ImagesPreviewDirective, "[ngImagesPreview]", never, { "highResSrc": { "alias": "ngImagesPreview"; "required": false; }; "previewImages": { "alias": "previewImages"; "required": false; }; "previewTemplate": { "alias": "previewTemplate"; "required": false; }; }, {}, never, never, true, never>;
|
|
259
|
+
static ɵdir: _angular_core.ɵɵDirectiveDeclaration<ImagesPreviewDirective, "[ngImagesPreview]", never, { "highResSrc": { "alias": "ngImagesPreview"; "required": false; }; "previewImages": { "alias": "previewImages"; "required": false; }; "previewTemplate": { "alias": "previewTemplate"; "required": false; }; "toolbarConfig": { "alias": "toolbarConfig"; "required": false; }; "srcset": { "alias": "srcset"; "required": false; }; "srcsets": { "alias": "srcsets"; "required": false; }; "showThumbnails": { "alias": "showThumbnails"; "required": false; }; "showToolbar": { "alias": "showToolbar"; "required": false; }; "toolbarExtensions": { "alias": "toolbarExtensions"; "required": false; }; }, {}, never, never, true, never>;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
declare class NgImagesPreviewModule {
|
|
263
|
+
static ɵfac: _angular_core.ɵɵFactoryDeclaration<NgImagesPreviewModule, never>;
|
|
264
|
+
static ɵmod: _angular_core.ɵɵNgModuleDeclaration<NgImagesPreviewModule, never, [typeof ImagesPreviewComponent, typeof ImagesPreviewDirective], [typeof ImagesPreviewComponent, typeof ImagesPreviewDirective]>;
|
|
265
|
+
static ɵinj: _angular_core.ɵɵInjectorDeclaration<NgImagesPreviewModule>;
|
|
116
266
|
}
|
|
117
267
|
|
|
118
|
-
export { ImagesPreviewComponent, ImagesPreviewDirective };
|
|
119
|
-
export type { ImagesPreviewActions, ImagesPreviewState };
|
|
268
|
+
export { ImagesPreviewComponent, ImagesPreviewDirective, NgImagesPreviewModule };
|
|
269
|
+
export type { ImagesPreviewActions, ImagesPreviewContext, ImagesPreviewState, ToolbarConfig };
|