@autotaxatiepartners/ngx-gallery 2.0.2 → 2.0.3
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/.editorconfig +13 -0
- package/.eslintrc.json +51 -0
- package/.travis.yml +38 -0
- package/angular.json +108 -0
- package/package.json +64 -37
- package/projects/gallery/.eslintrc.json +55 -0
- package/projects/gallery/README.md +24 -0
- package/projects/gallery/karma.conf.js +52 -0
- package/projects/gallery/ng-package.json +7 -0
- package/projects/gallery/package.json +32 -0
- package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.html +4 -0
- package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.scss +21 -0
- package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.spec.ts +25 -0
- package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.ts +28 -0
- package/projects/gallery/src/lib/ngx-gallery-action.ts +23 -0
- package/projects/gallery/src/lib/ngx-gallery-animation.ts +6 -0
- package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.html +27 -0
- package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.scss +45 -0
- package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.spec.ts +25 -0
- package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.ts +28 -0
- package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.html +4 -0
- package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.scss +26 -0
- package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.spec.ts +25 -0
- package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.ts +25 -0
- package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.html +49 -0
- package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.scss +106 -0
- package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.spec.ts +35 -0
- package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.ts +381 -0
- package/projects/gallery/src/lib/ngx-gallery-image-size.ts +4 -0
- package/projects/gallery/src/lib/ngx-gallery-image.ts +31 -0
- package/projects/gallery/src/lib/ngx-gallery-layout.ts +4 -0
- package/projects/gallery/src/lib/ngx-gallery-options.ts +261 -0
- package/projects/gallery/src/lib/ngx-gallery-order.ts +5 -0
- package/projects/gallery/src/lib/ngx-gallery-ordered-image.ts +19 -0
- package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.html +117 -0
- package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.scss +121 -0
- package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.spec.ts +34 -0
- package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.ts +619 -0
- package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.html +45 -0
- package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.scss +87 -0
- package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.spec.ts +31 -0
- package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.ts +298 -0
- package/projects/gallery/src/lib/ngx-gallery.component.html +53 -0
- package/projects/gallery/src/lib/ngx-gallery.component.scss +77 -0
- package/projects/gallery/src/lib/ngx-gallery.component.spec.ts +37 -0
- package/projects/gallery/src/lib/ngx-gallery.component.ts +336 -0
- package/projects/gallery/src/lib/ngx-gallery.module.ts +29 -0
- package/projects/gallery/src/lib/ngx-gallery.service.spec.ts +18 -0
- package/projects/gallery/src/lib/ngx-gallery.service.ts +71 -0
- package/projects/gallery/src/public-api.ts +20 -0
- package/projects/gallery/src/test.ts +17 -0
- package/projects/gallery/tsconfig.lib.json +14 -0
- package/projects/gallery/tsconfig.lib.prod.json +9 -0
- package/projects/gallery/tsconfig.spec.json +16 -0
- package/projects/gallery-app/.browserslistrc +12 -0
- package/projects/gallery-app/.eslintrc.json +40 -0
- package/projects/gallery-app/e2e/protractor.conf.js +32 -0
- package/projects/gallery-app/e2e/src/app.e2e-spec.ts +23 -0
- package/projects/gallery-app/e2e/src/app.po.ts +11 -0
- package/projects/gallery-app/e2e/tsconfig.json +13 -0
- package/projects/gallery-app/karma.conf.js +32 -0
- package/projects/gallery-app/src/app/app-routing.module.ts +11 -0
- package/projects/gallery-app/src/app/app.component.html +4 -0
- package/projects/gallery-app/src/app/app.component.scss +9 -0
- package/projects/gallery-app/src/app/app.component.spec.ts +35 -0
- package/projects/gallery-app/src/app/app.component.ts +82 -0
- package/projects/gallery-app/src/app/app.module.ts +20 -0
- package/projects/gallery-app/src/assets/.gitkeep +0 -0
- package/projects/gallery-app/src/assets/img/gallery/1-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/1-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/1-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/2-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/2-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/2-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/3-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/3-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/3-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/4-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/4-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/4-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/5-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/5-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/5-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/6-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/6-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/6-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/7-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/7-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/7-small.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/8-big.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/8-medium.jpeg +0 -0
- package/projects/gallery-app/src/assets/img/gallery/8-small.jpeg +0 -0
- package/projects/gallery-app/src/environments/environment.prod.ts +3 -0
- package/projects/gallery-app/src/environments/environment.ts +16 -0
- package/projects/gallery-app/src/favicon.ico +0 -0
- package/projects/gallery-app/src/index.html +13 -0
- package/projects/gallery-app/src/main.ts +12 -0
- package/projects/gallery-app/src/polyfills.ts +53 -0
- package/projects/gallery-app/src/styles.scss +1 -0
- package/projects/gallery-app/src/test.ts +16 -0
- package/projects/gallery-app/tsconfig.app.json +17 -0
- package/projects/gallery-app/tsconfig.spec.json +18 -0
- package/tsconfig.json +43 -0
- package/fesm2022/autotaxatiepartners-ngx-gallery.mjs +0 -1756
- package/fesm2022/autotaxatiepartners-ngx-gallery.mjs.map +0 -1
- package/index.d.ts +0 -591
|
@@ -0,0 +1,619 @@
|
|
|
1
|
+
import { AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, EventEmitter, HostListener, Input, OnDestroy, OnInit, Output, Renderer2, ViewChild } from '@angular/core';
|
|
2
|
+
import { DomSanitizer, SafeResourceUrl, SafeStyle, SafeUrl } from '@angular/platform-browser';
|
|
3
|
+
import { NgxGalleryService } from '../ngx-gallery.service';
|
|
4
|
+
import { NgxGalleryAction } from '../ngx-gallery-action';
|
|
5
|
+
|
|
6
|
+
@Component({
|
|
7
|
+
selector: 'ngx-gallery-preview',
|
|
8
|
+
templateUrl: './ngx-gallery-preview.component.html',
|
|
9
|
+
styleUrls: ['./ngx-gallery-preview.component.scss'],
|
|
10
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
11
|
+
standalone: false
|
|
12
|
+
})
|
|
13
|
+
export class NgxGalleryPreviewComponent implements OnInit, OnDestroy, AfterViewInit {
|
|
14
|
+
public src: SafeUrl;
|
|
15
|
+
public srcIndex: number;
|
|
16
|
+
public description: string;
|
|
17
|
+
public type: string;
|
|
18
|
+
public showSpinner = false;
|
|
19
|
+
public positionLeft = 0;
|
|
20
|
+
public positionTop = 0;
|
|
21
|
+
public zoomValue = 1;
|
|
22
|
+
public loading = false;
|
|
23
|
+
public rotateValue = 0;
|
|
24
|
+
public index = 0;
|
|
25
|
+
|
|
26
|
+
@Input() public images: string[] | SafeResourceUrl[];
|
|
27
|
+
@Input() public descriptions: string[];
|
|
28
|
+
@Input() public showDescription: boolean;
|
|
29
|
+
@Input() public arrows: boolean;
|
|
30
|
+
@Input() public arrowsAutoHide: boolean;
|
|
31
|
+
@Input() public swipe: boolean;
|
|
32
|
+
@Input() public fullscreen: boolean;
|
|
33
|
+
@Input() public forceFullscreen: boolean;
|
|
34
|
+
@Input() public closeOnClick: boolean;
|
|
35
|
+
@Input() public closeOnEsc: boolean;
|
|
36
|
+
@Input() public keyboardNavigation: boolean;
|
|
37
|
+
@Input() public arrowPrevIcon: string;
|
|
38
|
+
@Input() public arrowNextIcon: string;
|
|
39
|
+
@Input() public arrowIconSize: number;
|
|
40
|
+
@Input() public closeIcon: string;
|
|
41
|
+
@Input() public fullscreenIcon: string;
|
|
42
|
+
@Input() public spinnerIcon: string;
|
|
43
|
+
@Input() public autoPlay: boolean;
|
|
44
|
+
@Input() public autoPlayInterval: number;
|
|
45
|
+
@Input() public autoPlayPauseOnHover: boolean;
|
|
46
|
+
@Input() public infinityMove: boolean;
|
|
47
|
+
@Input() public zoom: boolean;
|
|
48
|
+
@Input() public zoomStep: number;
|
|
49
|
+
@Input() public zoomMax: number;
|
|
50
|
+
@Input() public zoomMin: number;
|
|
51
|
+
@Input() public zoomInIcon: string;
|
|
52
|
+
@Input() public zoomOutIcon: string;
|
|
53
|
+
@Input() public animation: boolean;
|
|
54
|
+
@Input() public actions: NgxGalleryAction[];
|
|
55
|
+
@Input() public rotate: boolean;
|
|
56
|
+
@Input() public rotateLeftIcon: string;
|
|
57
|
+
@Input() public rotateRightIcon: string;
|
|
58
|
+
@Input() public download: boolean;
|
|
59
|
+
@Input() public downloadIcon: string;
|
|
60
|
+
@Input() public bullets: boolean;
|
|
61
|
+
|
|
62
|
+
@Output() public previewOpen = new EventEmitter();
|
|
63
|
+
@Output() public previewClose = new EventEmitter();
|
|
64
|
+
@Output() public activeChange = new EventEmitter<number>();
|
|
65
|
+
|
|
66
|
+
@ViewChild('previewImage') public previewImage: any;
|
|
67
|
+
|
|
68
|
+
private isOpen = false;
|
|
69
|
+
private timer: any;
|
|
70
|
+
private initialX = 0;
|
|
71
|
+
private initialY = 0;
|
|
72
|
+
private initialLeft = 0;
|
|
73
|
+
private initialTop = 0;
|
|
74
|
+
private isMove = false;
|
|
75
|
+
|
|
76
|
+
private keyDownListener: () => void;
|
|
77
|
+
|
|
78
|
+
// interaction mode: 'none' | 'pan' | 'swipe'
|
|
79
|
+
private interactionMode: 'none' | 'pan' | 'swipe' = 'none';
|
|
80
|
+
|
|
81
|
+
// swipe tracking
|
|
82
|
+
private swipeStartX = 0;
|
|
83
|
+
private swipeStartY = 0;
|
|
84
|
+
public swipeOffsetX = 0;
|
|
85
|
+
public swipeAnimating = false;
|
|
86
|
+
|
|
87
|
+
constructor(
|
|
88
|
+
private sanitization: DomSanitizer,
|
|
89
|
+
private elementRef: ElementRef,
|
|
90
|
+
private helperService: NgxGalleryService,
|
|
91
|
+
private renderer: Renderer2,
|
|
92
|
+
private changeDetectorRef: ChangeDetectorRef
|
|
93
|
+
) { }
|
|
94
|
+
|
|
95
|
+
public ngOnInit(): void {
|
|
96
|
+
if (this.arrows && this.arrowsAutoHide) {
|
|
97
|
+
this.arrows = false;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
public ngAfterViewInit(): void {
|
|
102
|
+
// no external swiper hookup anymore
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
public ngOnDestroy(): void {
|
|
106
|
+
if (this.keyDownListener) {
|
|
107
|
+
this.keyDownListener();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@HostListener('mouseenter')
|
|
112
|
+
public onMouseEnter(): void {
|
|
113
|
+
if (this.arrowsAutoHide && !this.arrows) {
|
|
114
|
+
this.arrows = true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@HostListener('mouseleave')
|
|
119
|
+
public onMouseLeave(): void {
|
|
120
|
+
if (this.arrowsAutoHide && this.arrows) {
|
|
121
|
+
this.arrows = false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
public onKeyDown(e: KeyboardEvent): void {
|
|
126
|
+
if (!this.isOpen) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.keyboardNavigation) {
|
|
131
|
+
if (this.isKeyboardPrev(e)) {
|
|
132
|
+
this.showPrev();
|
|
133
|
+
} else if (this.isKeyboardNext(e)) {
|
|
134
|
+
this.showNext();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.closeOnEsc && this.isKeyboardEsc(e)) {
|
|
139
|
+
this.close();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
public open(index: number): void {
|
|
144
|
+
this.previewOpen.emit();
|
|
145
|
+
|
|
146
|
+
this.index = index;
|
|
147
|
+
this.isOpen = true;
|
|
148
|
+
this.show(true);
|
|
149
|
+
|
|
150
|
+
if (this.forceFullscreen) {
|
|
151
|
+
this.manageFullscreen();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
this.keyDownListener = this.renderer.listen('window', 'keydown', (e) => this.onKeyDown(e));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
public close(): void {
|
|
158
|
+
this.isOpen = false;
|
|
159
|
+
const video = this.previewImage?.nativeElement;
|
|
160
|
+
if (
|
|
161
|
+
video &&
|
|
162
|
+
video.currentTime > 0 &&
|
|
163
|
+
!video.paused &&
|
|
164
|
+
!video.ended &&
|
|
165
|
+
video.readyState > 2
|
|
166
|
+
) {
|
|
167
|
+
video.pause();
|
|
168
|
+
}
|
|
169
|
+
this.closeFullscreen();
|
|
170
|
+
this.previewClose.emit();
|
|
171
|
+
|
|
172
|
+
this.stopAutoPlay();
|
|
173
|
+
|
|
174
|
+
if (this.keyDownListener) {
|
|
175
|
+
this.keyDownListener();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public onWrapperClick(event: MouseEvent): void {
|
|
180
|
+
if (!this.closeOnClick) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.close();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
public imageMouseEnter(): void {
|
|
188
|
+
if (this.autoPlay && this.autoPlayPauseOnHover) {
|
|
189
|
+
this.stopAutoPlay();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
public imageMouseLeave(): void {
|
|
194
|
+
if (this.autoPlay && this.autoPlayPauseOnHover) {
|
|
195
|
+
this.startAutoPlay();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
public startAutoPlay(): void {
|
|
200
|
+
if (this.autoPlay) {
|
|
201
|
+
this.stopAutoPlay();
|
|
202
|
+
|
|
203
|
+
this.timer = setTimeout(() => {
|
|
204
|
+
if (!this.showNext()) {
|
|
205
|
+
this.index = -1;
|
|
206
|
+
this.showNext();
|
|
207
|
+
}
|
|
208
|
+
}, this.autoPlayInterval);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
public stopAutoPlay(): void {
|
|
213
|
+
if (this.timer) {
|
|
214
|
+
clearTimeout(this.timer);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
public showAtIndex(index: number): void {
|
|
219
|
+
this.index = index;
|
|
220
|
+
this.show();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
public showNext(): boolean {
|
|
224
|
+
if (this.canShowNext()) {
|
|
225
|
+
this.index++;
|
|
226
|
+
|
|
227
|
+
if (this.index === this.images.length) {
|
|
228
|
+
this.index = 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
this.show();
|
|
232
|
+
return true;
|
|
233
|
+
} else {
|
|
234
|
+
return false;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
public showPrev(): void {
|
|
239
|
+
if (this.canShowPrev()) {
|
|
240
|
+
this.index--;
|
|
241
|
+
|
|
242
|
+
if (this.index < 0) {
|
|
243
|
+
this.index = this.images.length - 1;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
this.show();
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
public canShowNext(): boolean {
|
|
251
|
+
if (this.loading) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
if (this.images) {
|
|
255
|
+
return this.infinityMove || this.index < this.images.length - 1;
|
|
256
|
+
}
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
public canShowPrev(): boolean {
|
|
261
|
+
if (this.loading) {
|
|
262
|
+
return false;
|
|
263
|
+
}
|
|
264
|
+
if (this.images) {
|
|
265
|
+
return this.infinityMove || this.index > 0;
|
|
266
|
+
}
|
|
267
|
+
return false;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
public manageFullscreen(): void {
|
|
271
|
+
if (this.fullscreen || this.forceFullscreen) {
|
|
272
|
+
const doc = document as any;
|
|
273
|
+
|
|
274
|
+
if (!doc.fullscreenElement && !doc.mozFullScreenElement
|
|
275
|
+
&& !doc.webkitFullscreenElement && !doc.msFullscreenElement) {
|
|
276
|
+
this.openFullscreen();
|
|
277
|
+
} else {
|
|
278
|
+
this.closeFullscreen();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
public getSafeUrl(image: string): SafeUrl {
|
|
284
|
+
return this.sanitization.bypassSecurityTrustUrl(image);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
public getFileType(fileSource: string): string {
|
|
288
|
+
return this.helperService.getFileType(fileSource);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
public zoomIn(): void {
|
|
292
|
+
if (this.canZoomIn()) {
|
|
293
|
+
this.zoomValue += this.zoomStep;
|
|
294
|
+
|
|
295
|
+
if (this.zoomValue > this.zoomMax) {
|
|
296
|
+
this.zoomValue = this.zoomMax;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public zoomOut(): void {
|
|
302
|
+
if (this.canZoomOut()) {
|
|
303
|
+
this.zoomValue -= this.zoomStep;
|
|
304
|
+
|
|
305
|
+
if (this.zoomValue < this.zoomMin) {
|
|
306
|
+
this.zoomValue = this.zoomMin;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (this.zoomValue <= 1) {
|
|
310
|
+
this.resetPosition();
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
public rotateLeft(): void {
|
|
316
|
+
this.rotateValue -= 90;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
public rotateRight(): void {
|
|
320
|
+
this.rotateValue += 90;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
public getTransform(): SafeStyle {
|
|
324
|
+
return this.sanitization.bypassSecurityTrustStyle(
|
|
325
|
+
'scale(' + this.zoomValue + ') rotate(' + this.rotateValue + 'deg)'
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
public canZoomIn(): boolean {
|
|
330
|
+
return this.zoomValue < this.zoomMax;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
public canZoomOut(): boolean {
|
|
334
|
+
return this.zoomValue > this.zoomMin;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
public canDragOnZoom(): boolean {
|
|
338
|
+
return this.zoom && this.zoomValue > 1;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// these 3 are the ones your current HTML calls
|
|
342
|
+
public mouseDownHandler(e: MouseEvent | TouchEvent): void {
|
|
343
|
+
this.onSwipeStart(e);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
public mouseMoveHandler(e: MouseEvent | TouchEvent): void {
|
|
347
|
+
this.onSwipeMove(e);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
public mouseUpHandler(e: MouseEvent | TouchEvent): void {
|
|
351
|
+
this.onSwipeEnd(e);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
// generic swipe/pan handlers
|
|
355
|
+
public onSwipeStart(e: MouseEvent | TouchEvent): void {
|
|
356
|
+
const x = this.getClientX(e);
|
|
357
|
+
const y = this.getClientY(e);
|
|
358
|
+
|
|
359
|
+
if (this.canDragOnZoom()) {
|
|
360
|
+
this.interactionMode = 'pan';
|
|
361
|
+
this.initialX = x;
|
|
362
|
+
this.initialY = y;
|
|
363
|
+
this.initialLeft = this.positionLeft;
|
|
364
|
+
this.initialTop = this.positionTop;
|
|
365
|
+
this.isMove = true;
|
|
366
|
+
} else if (this.swipe) {
|
|
367
|
+
this.interactionMode = 'swipe';
|
|
368
|
+
this.swipeStartX = x;
|
|
369
|
+
this.swipeStartY = y;
|
|
370
|
+
this.swipeOffsetX = 0;
|
|
371
|
+
this.swipeAnimating = false;
|
|
372
|
+
} else {
|
|
373
|
+
this.interactionMode = 'none';
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
public onSwipeMove(e: MouseEvent | TouchEvent): void {
|
|
378
|
+
if (this.interactionMode === 'pan') {
|
|
379
|
+
if (this.isMove) {
|
|
380
|
+
this.positionLeft = this.initialLeft + (this.getClientX(e) - this.initialX);
|
|
381
|
+
this.positionTop = this.initialTop + (this.getClientY(e) - this.initialY);
|
|
382
|
+
}
|
|
383
|
+
return;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (this.interactionMode === 'swipe') {
|
|
387
|
+
const currentX = this.getClientX(e);
|
|
388
|
+
const currentY = this.getClientY(e);
|
|
389
|
+
const deltaX = currentX - this.swipeStartX;
|
|
390
|
+
const deltaY = currentY - this.swipeStartY;
|
|
391
|
+
|
|
392
|
+
if (Math.abs(deltaY) > Math.abs(deltaX)) {
|
|
393
|
+
return;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
this.swipeOffsetX = deltaX;
|
|
397
|
+
e.preventDefault();
|
|
398
|
+
this.changeDetectorRef.markForCheck();
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
public onSwipeEnd(e: MouseEvent | TouchEvent): void {
|
|
403
|
+
if (this.interactionMode === 'pan') {
|
|
404
|
+
this.isMove = false;
|
|
405
|
+
this.interactionMode = 'none';
|
|
406
|
+
return;
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
if (this.interactionMode === 'swipe') {
|
|
410
|
+
const endX = this.getClientX(e);
|
|
411
|
+
const endY = this.getClientY(e);
|
|
412
|
+
const deltaX = endX - this.swipeStartX;
|
|
413
|
+
const deltaY = endY - this.swipeStartY;
|
|
414
|
+
|
|
415
|
+
const horizontalThreshold = 60;
|
|
416
|
+
const verticalThreshold = 80;
|
|
417
|
+
|
|
418
|
+
if (Math.abs(deltaX) > horizontalThreshold && Math.abs(deltaY) < verticalThreshold) {
|
|
419
|
+
if (deltaX < 0) {
|
|
420
|
+
if (this.canShowNext()) {
|
|
421
|
+
this.animateSwipeTo(-100);
|
|
422
|
+
this.showNext();
|
|
423
|
+
} else {
|
|
424
|
+
this.animateSwipeTo(0);
|
|
425
|
+
}
|
|
426
|
+
} else {
|
|
427
|
+
if (this.canShowPrev()) {
|
|
428
|
+
this.animateSwipeTo(100);
|
|
429
|
+
this.showPrev();
|
|
430
|
+
} else {
|
|
431
|
+
this.animateSwipeTo(0);
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
} else {
|
|
435
|
+
this.animateSwipeTo(0);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
this.interactionMode = 'none';
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
private animateSwipeTo(percent: number): void {
|
|
443
|
+
this.swipeAnimating = true;
|
|
444
|
+
if (percent === 0) {
|
|
445
|
+
this.swipeOffsetX = 0;
|
|
446
|
+
this.changeDetectorRef.markForCheck();
|
|
447
|
+
setTimeout(() => {
|
|
448
|
+
this.swipeAnimating = false;
|
|
449
|
+
this.changeDetectorRef.markForCheck();
|
|
450
|
+
}, 200);
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
this.swipeOffsetX = (percent / 100) * this.getPreviewWidth();
|
|
455
|
+
this.changeDetectorRef.markForCheck();
|
|
456
|
+
setTimeout(() => {
|
|
457
|
+
this.swipeOffsetX = 0;
|
|
458
|
+
this.swipeAnimating = false;
|
|
459
|
+
this.changeDetectorRef.markForCheck();
|
|
460
|
+
}, 200);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
public getSwipeTransform(): string {
|
|
464
|
+
if (!this.swipeOffsetX) {
|
|
465
|
+
return 'translateX(0px)';
|
|
466
|
+
}
|
|
467
|
+
return 'translateX(' + this.swipeOffsetX + 'px)';
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
private getPreviewWidth(): number {
|
|
471
|
+
const host = this.elementRef.nativeElement as HTMLElement;
|
|
472
|
+
const el = host.querySelector('.ngx-gallery-preview-img-wrapper') as HTMLElement;
|
|
473
|
+
if (el) {
|
|
474
|
+
return el.clientWidth;
|
|
475
|
+
}
|
|
476
|
+
return 300;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
private getClientX(e: MouseEvent | TouchEvent): number {
|
|
480
|
+
const touchEvent = e as TouchEvent;
|
|
481
|
+
if (touchEvent.touches && touchEvent.touches.length) {
|
|
482
|
+
return touchEvent.touches[0].clientX;
|
|
483
|
+
}
|
|
484
|
+
if (touchEvent.changedTouches && touchEvent.changedTouches.length) {
|
|
485
|
+
return touchEvent.changedTouches[0].clientX;
|
|
486
|
+
}
|
|
487
|
+
const mouseEvent = e as MouseEvent;
|
|
488
|
+
return mouseEvent.clientX;
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
private getClientY(e: MouseEvent | TouchEvent): number {
|
|
492
|
+
const touchEvent = e as TouchEvent;
|
|
493
|
+
if (touchEvent.touches && touchEvent.touches.length) {
|
|
494
|
+
return touchEvent.touches[0].clientY;
|
|
495
|
+
}
|
|
496
|
+
if (touchEvent.changedTouches && touchEvent.changedTouches.length) {
|
|
497
|
+
return touchEvent.changedTouches[0].clientY;
|
|
498
|
+
}
|
|
499
|
+
const mouseEvent = e as MouseEvent;
|
|
500
|
+
return mouseEvent.clientY;
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
private resetPosition(): void {
|
|
504
|
+
if (this.zoom) {
|
|
505
|
+
this.positionLeft = 0;
|
|
506
|
+
this.positionTop = 0;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
private isKeyboardNext(e: KeyboardEvent): boolean {
|
|
511
|
+
return e.keyCode === 39;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
private isKeyboardPrev(e: KeyboardEvent): boolean {
|
|
515
|
+
return e.keyCode === 37;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
private isKeyboardEsc(e: KeyboardEvent): boolean {
|
|
519
|
+
return e.keyCode === 27;
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
private openFullscreen(): void {
|
|
523
|
+
const element = document.documentElement as any;
|
|
524
|
+
|
|
525
|
+
if (element.requestFullscreen) {
|
|
526
|
+
element.requestFullscreen();
|
|
527
|
+
} else if (element.msRequestFullscreen) {
|
|
528
|
+
element.msRequestFullscreen();
|
|
529
|
+
} else if (element.mozRequestFullScreen) {
|
|
530
|
+
element.mozRequestFullScreen();
|
|
531
|
+
} else if (element.webkitRequestFullscreen) {
|
|
532
|
+
element.webkitRequestFullscreen();
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
private closeFullscreen(): void {
|
|
537
|
+
if (this.isFullscreen()) {
|
|
538
|
+
const doc = document as any;
|
|
539
|
+
|
|
540
|
+
if (doc.exitFullscreen) {
|
|
541
|
+
doc.exitFullscreen();
|
|
542
|
+
} else if (doc.msExitFullscreen) {
|
|
543
|
+
doc.msExitFullscreen();
|
|
544
|
+
} else if (doc.mozCancelFullScreen) {
|
|
545
|
+
doc.mozCancelFullScreen();
|
|
546
|
+
} else if (doc.webkitExitFullscreen) {
|
|
547
|
+
doc.webkitExitFullscreen();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
private isFullscreen(): boolean {
|
|
553
|
+
const doc = document as any;
|
|
554
|
+
|
|
555
|
+
return doc.fullscreenElement || doc.webkitFullscreenElement
|
|
556
|
+
|| doc.mozFullScreenElement || doc.msFullscreenElement;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
private show(first = false): void {
|
|
560
|
+
this.loading = true;
|
|
561
|
+
this.stopAutoPlay();
|
|
562
|
+
|
|
563
|
+
this.activeChange.emit(this.index);
|
|
564
|
+
|
|
565
|
+
this.swipeOffsetX = 0;
|
|
566
|
+
this.swipeAnimating = false;
|
|
567
|
+
|
|
568
|
+
if (first || !this.animation) {
|
|
569
|
+
this._show();
|
|
570
|
+
} else {
|
|
571
|
+
setTimeout(() => this._show(), 600);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
private _show(): void {
|
|
576
|
+
this.zoomValue = 1;
|
|
577
|
+
this.rotateValue = 0;
|
|
578
|
+
this.resetPosition();
|
|
579
|
+
|
|
580
|
+
this.src = this.getSafeUrl(this.images[this.index] as string);
|
|
581
|
+
this.type = this.getFileType(this.images[this.index] as string);
|
|
582
|
+
this.srcIndex = this.index;
|
|
583
|
+
this.description = this.descriptions?.[this.index];
|
|
584
|
+
this.changeDetectorRef.markForCheck();
|
|
585
|
+
|
|
586
|
+
setTimeout(() => {
|
|
587
|
+
if (this.isLoaded(this.previewImage?.nativeElement) || this.type === 'video') {
|
|
588
|
+
this.loading = false;
|
|
589
|
+
this.startAutoPlay();
|
|
590
|
+
this.changeDetectorRef.markForCheck();
|
|
591
|
+
} else {
|
|
592
|
+
setTimeout(() => {
|
|
593
|
+
if (this.loading) {
|
|
594
|
+
this.showSpinner = true;
|
|
595
|
+
this.changeDetectorRef.markForCheck();
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
|
|
599
|
+
if (this.previewImage && this.previewImage.nativeElement) {
|
|
600
|
+
this.previewImage.nativeElement.onload = () => {
|
|
601
|
+
this.loading = false;
|
|
602
|
+
this.showSpinner = false;
|
|
603
|
+
this.previewImage.nativeElement.onload = null;
|
|
604
|
+
this.startAutoPlay();
|
|
605
|
+
this.changeDetectorRef.markForCheck();
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
private isLoaded(img: any): boolean {
|
|
613
|
+
if (!img || !img.complete) {
|
|
614
|
+
return false;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
return !(typeof img.naturalWidth !== 'undefined' && img.naturalWidth === 0);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<div class="ngx-gallery-thumbnails-wrapper ngx-gallery-thumbnail-size-{{size}}">
|
|
2
|
+
<div class="ngx-gallery-thumbnails" [style.transform]="'translateX(' + thumbnailsLeft + ')'"
|
|
3
|
+
[style.marginLeft]="thumbnailsMarginLeft">
|
|
4
|
+
@for (image of getImages(); track image; let i = $index) {
|
|
5
|
+
<a [href]="hasLink(i) ? links[i] : '#'" [target]="linkTarget" class="ngx-gallery-thumbnail"
|
|
6
|
+
(click)="handleClick($event, i)" [style.width]="getThumbnailWidth()" [style.height]="getThumbnailHeight()"
|
|
7
|
+
[style.left]="getThumbnailLeft(i)" [style.top]="getThumbnailTop(i)"
|
|
8
|
+
[ngClass]="{ 'ngx-gallery-active': i === selectedIndex, 'ngx-gallery-clickable': clickable }"
|
|
9
|
+
[attr.aria-label]="labels[i]">
|
|
10
|
+
@if (getFileType(image) === 'image') {
|
|
11
|
+
<div [style.background-image]="getSafeUrl(image)" class="ngx-gallery-thumbnail"
|
|
12
|
+
[ngClass]="{ 'ngx-gallery-active': i === selectedIndex, 'ngx-gallery-clickable': clickable }"
|
|
13
|
+
style="width: 100%; height: 100%; position:absolute;"></div>
|
|
14
|
+
}
|
|
15
|
+
@if (getFileType(image) === 'video') {
|
|
16
|
+
<div class="ngx-gallery-thumbnail-video">
|
|
17
|
+
<video class="ngx-gallery-thumbnail"
|
|
18
|
+
[ngClass]="{ 'ngx-gallery-active': i === selectedIndex, 'ngx-gallery-clickable': clickable }"
|
|
19
|
+
style="width: 100%; height: 100%; position:absolute; left:0; background:#000;">
|
|
20
|
+
<source [src]="image">
|
|
21
|
+
Your browser does not support the video tag.
|
|
22
|
+
</video>
|
|
23
|
+
</div>
|
|
24
|
+
}
|
|
25
|
+
<div class="ngx-gallery-icons-wrapper">
|
|
26
|
+
@for (action of actions; track action) {
|
|
27
|
+
<ngx-gallery-action [icon]="action.icon" [disabled]="action.disabled" [titleText]="action.titleText"
|
|
28
|
+
(closeClick)="action.onClick($event, i)"></ngx-gallery-action>
|
|
29
|
+
}
|
|
30
|
+
</div>
|
|
31
|
+
@if (remainingCount && remainingCountValue && (i === (rows * columns) - 1)) {
|
|
32
|
+
<div class="ngx-gallery-remaining-count-overlay">
|
|
33
|
+
<span class="ngx-gallery-remaining-count">+{{remainingCountValue}}</span>
|
|
34
|
+
</div>
|
|
35
|
+
}
|
|
36
|
+
</a>
|
|
37
|
+
}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
@if (canShowArrows()) {
|
|
42
|
+
<ngx-gallery-arrows (prevClick)="moveLeft()" (nextClick)="moveRight()" [prevDisabled]="!canMoveLeft()"
|
|
43
|
+
[nextDisabled]="!canMoveRight()" [arrowPrevIcon]="arrowPrevIcon" [arrowNextIcon]="arrowNextIcon"
|
|
44
|
+
[arrowIconSize]="arrowIconThumbnailSize"></ngx-gallery-arrows>
|
|
45
|
+
}
|