ng-images-preview 1.0.3 → 2.0.1

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