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.
package/README.md CHANGED
@@ -28,12 +28,16 @@ Check out the component in action: **[https://lanxuexing.github.io/ng-images-pre
28
28
  - 🎨 **Vanilla CSS**: Zero dependencies, fully customizable via CSS variables.
29
29
  - 🖼️ **Multi-Image Gallery**: Navigate through a list of images with arrows or swipe gestures.
30
30
  - 📱 **Mobile Ready**: Swipe to navigate, double-tap to zoom, pinch-to-zoom gestures.
31
+ - 👆 **Pull-to-Close**: Drag down to close the preview (like native apps).
32
+ - 🎞️ **Thumbnail Strip**: Quick preview and navigation with an auto-scrolling strip.
33
+ - 🧩 **Toolbar Extensions**: Inject custom buttons (like Download) into the toolbar.
34
+ - 🤝 **Hybrid Support**: Fully compatible with both Standalone and NgModule-based apps.
31
35
  - ⌨️ **Keyboard Support**: Arrow keys to navigate, ESC to close.
32
36
  - 🔍 **Zoom & Pan**: Smooth zooming and panning interactions.
33
37
  - 🔄 **Rotate & Flip**: Built-in toolbar for image manipulation.
34
- - 🧩 **Custom Template**: Complete control over the preview UI via `ng-template`.
38
+ - 🎨 **Custom Template**: Complete control over the preview UI via `ng-template`.
35
39
  - ♿ **Accessible**: ARIA labels and focus management.
36
- - ⚡ **Performance**: Smart image preloading for smoother gallery navigation.
40
+ - ⚡ **Performance**: Smart image preloading and buffering for smoother navigation.
37
41
  - 🌏 **SSR Safe**: Fully compatible with Angular Universal/SSR.
38
42
  - 🌗 **Dark Mode Ready**: Inherits system preferences or app styles seamlessly.
39
43
 
@@ -70,10 +74,9 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
70
74
  export class AppModule { }
71
75
  ```
72
76
 
73
- ### 1. Import Directive
74
-
75
- Register `ImagesPreviewDirective` in your standalone component or module.
77
+ Register the library in your standalone component or module.
76
78
 
79
+ #### Standalone (Recommended)
77
80
  ```typescript
78
81
  import { ImagesPreviewDirective } from 'ng-images-preview';
79
82
 
@@ -84,6 +87,16 @@ import { ImagesPreviewDirective } from 'ng-images-preview';
84
87
  export class MyComponent {}
85
88
  ```
86
89
 
90
+ #### NgModule (Legacy Support)
91
+ ```typescript
92
+ import { NgImagesPreviewModule } from 'ng-images-preview';
93
+
94
+ @NgModule({
95
+ imports: [NgImagesPreviewModule, ...]
96
+ })
97
+ export class AppModule {}
98
+ ```
99
+
87
100
  ### 2. Basic Usage
88
101
 
89
102
  **Option A: Zero Config** (Auto-detects source)
@@ -101,12 +114,33 @@ export class MyComponent {}
101
114
  ```
102
115
 
103
116
  **Option C: Gallery Mode**
104
- Pass a list of images to `previewImages` to enable gallery navigation (arrows, swipe).
117
+ Pass a list of images to `previewImages` to enable gallery navigation and the automatic **Thumbnail Strip**.
105
118
  ```html
106
119
  <img
107
120
  src="item1.jpg"
108
121
  [ngImagesPreview]="'item1-highres.jpg'"
109
- [previewImages]="['item1-highres.jpg', 'item2-highres.jpg', 'item3-highres.jpg']">
122
+ [previewImages]="['item1.jpg', 'item2.jpg', 'item3.jpg']">
123
+ ```
124
+
125
+ **Option D: Toolbar Extensions**
126
+ Add custom buttons (like Download) using an `ng-template`.
127
+ ```html
128
+ <ng-template #myExtraButtons>
129
+ <button class="toolbar-btn" (click)="download()">
130
+ <svg>...</svg>
131
+ </button>
132
+ </ng-template>
133
+
134
+ <img src="pic.jpg" ngImagesPreview [toolbarExtensions]="myExtraButtons">
135
+ ```
136
+
137
+ **Option E: Performance (Srcsets)**
138
+ Support responsive images for faster loading on mobile.
139
+ ```html
140
+ <img
141
+ src="thumb.jpg"
142
+ ngImagesPreview
143
+ [previewSrcsets]="['image-400w.jpg 400w, image-800w.jpg 800w']">
110
144
  ```
111
145
 
112
146
  ### 3. Custom Template
@@ -134,6 +168,10 @@ Take full control of the UI by providing a template.
134
168
  | `ngImagesPreview` | `string` | `''` | High-res URL. If empty, tries to read `src` from host or child `img`. |
135
169
  | `previewImages` | `string[]` | `[]` | List of image URLs for gallery navigation. |
136
170
  | `previewTemplate` | `TemplateRef` | `undefined` | Custom template to render instead of the default viewer. |
171
+ | `previewSrcsets` | `string[]` | `[]` | List of `srcset` strings for gallery navigation. |
172
+ | `showThumbnails` | `boolean` | `true` | Whether to show the thumbnail strip. |
173
+ | `showToolbar` | `boolean` | `true` | Whether to show the top toolbar. |
174
+ | `toolbarExtensions`| `TemplateRef` | `undefined` | Custom template for toolbar buttons. |
137
175
 
138
176
  ### Component Inputs (`ImagesPreviewComponent`)
139
177
 
@@ -145,6 +183,10 @@ If you use the component directly:
145
183
  | `images` | `string[]` | `[]` | List of images for gallery. |
146
184
  | `initialIndex` | `number` | `0` | Initial image index in gallery. |
147
185
  | `customTemplate` | `TemplateRef` | `undefined` | Custom template for the overlay content. |
186
+ | `srcsets` | `string[]` | `[]` | List of `srcset` strings for images. |
187
+ | `showThumbnails` | `boolean` | `true` | Whether to show the thumbnail strip. |
188
+ | `showToolbar` | `boolean` | `true` | Whether to show the top toolbar. |
189
+ | `toolbarExtensions`| `TemplateRef` | `undefined` | Custom template for toolbar buttons. |
148
190
 
149
191
  ### Template Context (for Custom Templates)
150
192
 
@@ -160,6 +202,8 @@ When using `previewTemplate`, you get access to:
160
202
  | `flipV` | `boolean` | Vertical flip state. |
161
203
  | `isLoading` | `boolean` | True if image is loading. |
162
204
  | `hasError` | `boolean` | True if image failed to load. |
205
+ | `currentIndex` | `number` | Current index in gallery (0-based). |
206
+ | `total` | `number` | Total number of images in gallery. |
163
207
 
164
208
  #### `actions`
165
209
  | Method | Description |
@@ -174,6 +218,36 @@ When using `previewTemplate`, you get access to:
174
218
  | `close()` | Close the preview. |
175
219
  | `next()` | Go to next image (if gallery). |
176
220
  | `prev()` | Go to previous image (if gallery). |
221
+ | `jumpTo(index)` | Jump to a specific index in gallery. |
222
+
223
+ ### CSS Variables (Theming)
224
+
225
+ You can customize the look and feel by overriding these CSS variables in your `styles.css` or component styles:
226
+
227
+ ```css
228
+ :root {
229
+ /* Overlay */
230
+ --ng-img-background: rgba(0, 0, 0, 0.95);
231
+ --ng-img-text-color: rgba(255, 255, 255, 0.8);
232
+ --ng-img-z-index: 50;
233
+
234
+ /* Toolbar */
235
+ --ng-img-toolbar-bg: rgba(255, 255, 255, 0.1);
236
+ --ng-img-toolbar-hover: rgba(255, 255, 255, 0.2);
237
+ --ng-img-gap: 16px;
238
+
239
+ /* Thumbnails */
240
+ --ng-img-thumb-strip-bg: rgba(0, 0, 0, 0.4);
241
+ --ng-img-thumb-width: 60px;
242
+ --ng-img-thumb-height: 40px;
243
+ --ng-img-thumb-gap: 8px;
244
+ --ng-img-thumb-border-radius: 6px;
245
+ --ng-img-thumb-active-border: white;
246
+
247
+ /* Misc */
248
+ --ng-img-item-bg: rgba(0, 0, 0, 0.3);
249
+ }
250
+ ```
177
251
 
178
252
 
179
253