@autotaxatiepartners/ngx-gallery 1.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/.editorconfig +13 -0
- package/.eslintrc.json +51 -0
- package/.travis.yml +38 -0
- package/CHANGELOG.md +16 -0
- package/LICENSE +22 -0
- package/README.md +296 -0
- package/angular.json +108 -0
- package/package.json +71 -0
- 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 +12 -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 +395 -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 +255 -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 +66 -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 +486 -0
- package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.html +44 -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 +297 -0
- package/projects/gallery/src/lib/ngx-gallery.component.html +53 -0
- package/projects/gallery/src/lib/ngx-gallery.component.scss +78 -0
- package/projects/gallery/src/lib/ngx-gallery.component.spec.ts +37 -0
- package/projects/gallery/src/lib/ngx-gallery.component.ts +337 -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 +76 -0
- package/projects/gallery-app/src/app/app.module.ts +21 -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
|
@@ -0,0 +1,486 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AfterViewInit,
|
|
3
|
+
ChangeDetectionStrategy,
|
|
4
|
+
ChangeDetectorRef,
|
|
5
|
+
Component,
|
|
6
|
+
ElementRef,
|
|
7
|
+
EventEmitter,
|
|
8
|
+
HostListener,
|
|
9
|
+
Input,
|
|
10
|
+
OnDestroy,
|
|
11
|
+
OnInit,
|
|
12
|
+
Output,
|
|
13
|
+
Renderer2,
|
|
14
|
+
ViewChild
|
|
15
|
+
} from '@angular/core';
|
|
16
|
+
import { DomSanitizer, SafeResourceUrl, SafeStyle, SafeUrl } from '@angular/platform-browser';
|
|
17
|
+
import { NgxGalleryService } from '../ngx-gallery.service';
|
|
18
|
+
import { NgxGalleryAction } from '../ngx-gallery-action';
|
|
19
|
+
|
|
20
|
+
@Component({
|
|
21
|
+
selector: 'ngx-gallery-preview',
|
|
22
|
+
templateUrl: './ngx-gallery-preview.component.html',
|
|
23
|
+
styleUrls: ['./ngx-gallery-preview.component.scss'],
|
|
24
|
+
// encapsulation: ViewEncapsulation.None,
|
|
25
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
26
|
+
standalone: false
|
|
27
|
+
})
|
|
28
|
+
export class NgxGalleryPreviewComponent implements OnInit, OnDestroy, AfterViewInit {
|
|
29
|
+
src: SafeUrl;
|
|
30
|
+
srcIndex: number;
|
|
31
|
+
description: string;
|
|
32
|
+
type: string;
|
|
33
|
+
showSpinner = false;
|
|
34
|
+
positionLeft = 0;
|
|
35
|
+
positionTop = 0;
|
|
36
|
+
zoomValue = 1;
|
|
37
|
+
loading = false;
|
|
38
|
+
rotateValue = 0;
|
|
39
|
+
index = 0;
|
|
40
|
+
|
|
41
|
+
@Input() images: string[] | SafeResourceUrl[];
|
|
42
|
+
@Input() descriptions: string[];
|
|
43
|
+
@Input() showDescription: boolean;
|
|
44
|
+
@Input() arrows: boolean;
|
|
45
|
+
@Input() arrowsAutoHide: boolean;
|
|
46
|
+
@Input() swipe: boolean;
|
|
47
|
+
@Input() fullscreen: boolean;
|
|
48
|
+
@Input() forceFullscreen: boolean;
|
|
49
|
+
@Input() closeOnClick: boolean;
|
|
50
|
+
@Input() closeOnEsc: boolean;
|
|
51
|
+
@Input() keyboardNavigation: boolean;
|
|
52
|
+
@Input() arrowPrevIcon: string;
|
|
53
|
+
@Input() arrowNextIcon: string;
|
|
54
|
+
@Input() closeIcon: string;
|
|
55
|
+
@Input() fullscreenIcon: string;
|
|
56
|
+
@Input() spinnerIcon: string;
|
|
57
|
+
@Input() autoPlay: boolean;
|
|
58
|
+
@Input() autoPlayInterval: number;
|
|
59
|
+
@Input() autoPlayPauseOnHover: boolean;
|
|
60
|
+
@Input() infinityMove: boolean;
|
|
61
|
+
@Input() zoom: boolean;
|
|
62
|
+
@Input() zoomStep: number;
|
|
63
|
+
@Input() zoomMax: number;
|
|
64
|
+
@Input() zoomMin: number;
|
|
65
|
+
@Input() zoomInIcon: string;
|
|
66
|
+
@Input() zoomOutIcon: string;
|
|
67
|
+
@Input() animation: boolean;
|
|
68
|
+
@Input() actions: NgxGalleryAction[];
|
|
69
|
+
@Input() rotate: boolean;
|
|
70
|
+
@Input() rotateLeftIcon: string;
|
|
71
|
+
@Input() rotateRightIcon: string;
|
|
72
|
+
@Input() download: boolean;
|
|
73
|
+
@Input() downloadIcon: string;
|
|
74
|
+
@Input() bullets: boolean;
|
|
75
|
+
|
|
76
|
+
@Output() previewOpen = new EventEmitter();
|
|
77
|
+
@Output() previewClose = new EventEmitter();
|
|
78
|
+
@Output() activeChange = new EventEmitter<number>();
|
|
79
|
+
|
|
80
|
+
@ViewChild('previewImage') previewImage: any;
|
|
81
|
+
|
|
82
|
+
private isOpen = false;
|
|
83
|
+
private timer;
|
|
84
|
+
private initialX = 0;
|
|
85
|
+
private initialY = 0;
|
|
86
|
+
private initialLeft = 0;
|
|
87
|
+
private initialTop = 0;
|
|
88
|
+
private isMove = false;
|
|
89
|
+
|
|
90
|
+
private keyDownListener: () => void;
|
|
91
|
+
|
|
92
|
+
constructor(
|
|
93
|
+
private sanitization: DomSanitizer,
|
|
94
|
+
private elementRef: ElementRef,
|
|
95
|
+
private helperService: NgxGalleryService,
|
|
96
|
+
private renderer: Renderer2,
|
|
97
|
+
private changeDetectorRef: ChangeDetectorRef
|
|
98
|
+
) {}
|
|
99
|
+
|
|
100
|
+
ngOnInit() {
|
|
101
|
+
if (this.arrows && this.arrowsAutoHide) {
|
|
102
|
+
this.arrows = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
ngAfterViewInit(): void {
|
|
107
|
+
if (this.swipe) {
|
|
108
|
+
this.helperService.manageSwipe(
|
|
109
|
+
true,
|
|
110
|
+
this.elementRef,
|
|
111
|
+
'preview',
|
|
112
|
+
() => this.showNext(),
|
|
113
|
+
() => this.showPrev()
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
ngOnDestroy(): void {
|
|
119
|
+
this.helperService.manageSwipe(false, this.elementRef, 'preview', () => {}, () => {});
|
|
120
|
+
if (this.keyDownListener) {
|
|
121
|
+
this.keyDownListener();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@HostListener('mouseenter') onMouseEnter() {
|
|
126
|
+
if (this.arrowsAutoHide && !this.arrows) {
|
|
127
|
+
this.arrows = true;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@HostListener('mouseleave') onMouseLeave() {
|
|
132
|
+
if (this.arrowsAutoHide && this.arrows) {
|
|
133
|
+
this.arrows = false;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
onKeyDown(e) {
|
|
138
|
+
if (this.isOpen) {
|
|
139
|
+
if (this.keyboardNavigation) {
|
|
140
|
+
if (this.isKeyboardPrev(e)) {
|
|
141
|
+
this.showPrev();
|
|
142
|
+
} else if (this.isKeyboardNext(e)) {
|
|
143
|
+
this.showNext();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
if (this.closeOnEsc && this.isKeyboardEsc(e)) {
|
|
147
|
+
this.close();
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
open(index: number): void {
|
|
153
|
+
this.previewOpen.emit();
|
|
154
|
+
|
|
155
|
+
this.index = index;
|
|
156
|
+
this.isOpen = true;
|
|
157
|
+
this.show(true);
|
|
158
|
+
|
|
159
|
+
if (this.forceFullscreen) {
|
|
160
|
+
this.manageFullscreen();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
this.keyDownListener = this.renderer.listen('window', 'keydown', (e) => this.onKeyDown(e));
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
close(): void {
|
|
167
|
+
this.isOpen = false;
|
|
168
|
+
const video = this.previewImage.nativeElement;
|
|
169
|
+
if (
|
|
170
|
+
video.currentTime > 0 &&
|
|
171
|
+
!video.paused &&
|
|
172
|
+
!video.ended &&
|
|
173
|
+
video.readyState > 2
|
|
174
|
+
) {
|
|
175
|
+
video.pause();
|
|
176
|
+
}
|
|
177
|
+
this.closeFullscreen();
|
|
178
|
+
this.previewClose.emit();
|
|
179
|
+
|
|
180
|
+
this.stopAutoPlay();
|
|
181
|
+
|
|
182
|
+
if (this.keyDownListener) {
|
|
183
|
+
this.keyDownListener();
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
imageMouseEnter(): void {
|
|
188
|
+
if (this.autoPlay && this.autoPlayPauseOnHover) {
|
|
189
|
+
this.stopAutoPlay();
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
imageMouseLeave(): void {
|
|
194
|
+
if (this.autoPlay && this.autoPlayPauseOnHover) {
|
|
195
|
+
this.startAutoPlay();
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
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
|
+
stopAutoPlay(): void {
|
|
213
|
+
if (this.timer) {
|
|
214
|
+
clearTimeout(this.timer);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
showAtIndex(index: number): void {
|
|
219
|
+
this.index = index;
|
|
220
|
+
this.show();
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
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
|
+
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
|
+
canShowNext(): boolean {
|
|
251
|
+
if (this.loading) {
|
|
252
|
+
return false;
|
|
253
|
+
} else if (this.images) {
|
|
254
|
+
return this.infinityMove || this.index < this.images.length - 1;
|
|
255
|
+
} else {
|
|
256
|
+
return false;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
canShowPrev(): boolean {
|
|
261
|
+
if (this.loading) {
|
|
262
|
+
return false;
|
|
263
|
+
} else if (this.images) {
|
|
264
|
+
return this.infinityMove || this.index > 0;
|
|
265
|
+
} else {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
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
|
+
getSafeUrl(image: string): SafeUrl {
|
|
284
|
+
return this.sanitization.bypassSecurityTrustUrl(image);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getFileType(fileSource: string): string {
|
|
288
|
+
return this.helperService.getFileType(fileSource);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
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
|
+
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
|
+
rotateLeft(): void {
|
|
316
|
+
this.rotateValue -= 90;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
rotateRight(): void {
|
|
320
|
+
this.rotateValue += 90;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
getTransform(): SafeStyle {
|
|
324
|
+
return this.sanitization.bypassSecurityTrustStyle('scale(' + this.zoomValue + ') rotate(' + this.rotateValue + 'deg)');
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
canZoomIn(): boolean {
|
|
328
|
+
return this.zoomValue < this.zoomMax;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
canZoomOut(): boolean {
|
|
332
|
+
return this.zoomValue > this.zoomMin;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
canDragOnZoom() {
|
|
336
|
+
return this.zoom && this.zoomValue > 1;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
mouseDownHandler(e): void {
|
|
340
|
+
if (this.canDragOnZoom()) {
|
|
341
|
+
this.initialX = this.getClientX(e);
|
|
342
|
+
this.initialY = this.getClientY(e);
|
|
343
|
+
this.initialLeft = this.positionLeft;
|
|
344
|
+
this.initialTop = this.positionTop;
|
|
345
|
+
this.isMove = true;
|
|
346
|
+
|
|
347
|
+
e.preventDefault();
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
mouseUpHandler(e): void {
|
|
352
|
+
this.isMove = false;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
mouseMoveHandler(e) {
|
|
356
|
+
if (this.isMove) {
|
|
357
|
+
this.positionLeft = this.initialLeft + (this.getClientX(e) - this.initialX);
|
|
358
|
+
this.positionTop = this.initialTop + (this.getClientY(e) - this.initialY);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
private getClientX(e): number {
|
|
363
|
+
return e.touches && e.touches.length ? e.touches[0].clientX : e.clientX;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
private getClientY(e): number {
|
|
367
|
+
return e.touches && e.touches.length ? e.touches[0].clientY : e.clientY;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
private resetPosition() {
|
|
371
|
+
if (this.zoom) {
|
|
372
|
+
this.positionLeft = 0;
|
|
373
|
+
this.positionTop = 0;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
private isKeyboardNext(e): boolean {
|
|
378
|
+
return e.keyCode === 39;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
private isKeyboardPrev(e): boolean {
|
|
382
|
+
return e.keyCode === 37;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
private isKeyboardEsc(e): boolean {
|
|
386
|
+
return e.keyCode === 27;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
private openFullscreen(): void {
|
|
390
|
+
const element = document.documentElement as any;
|
|
391
|
+
|
|
392
|
+
if (element.requestFullscreen) {
|
|
393
|
+
element.requestFullscreen();
|
|
394
|
+
} else if (element.msRequestFullscreen) {
|
|
395
|
+
element.msRequestFullscreen();
|
|
396
|
+
} else if (element.mozRequestFullScreen) {
|
|
397
|
+
element.mozRequestFullScreen();
|
|
398
|
+
} else if (element.webkitRequestFullscreen) {
|
|
399
|
+
element.webkitRequestFullscreen();
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
private closeFullscreen(): void {
|
|
404
|
+
if (this.isFullscreen()) {
|
|
405
|
+
const doc = document as any;
|
|
406
|
+
|
|
407
|
+
if (doc.exitFullscreen) {
|
|
408
|
+
doc.exitFullscreen();
|
|
409
|
+
} else if (doc.msExitFullscreen) {
|
|
410
|
+
doc.msExitFullscreen();
|
|
411
|
+
} else if (doc.mozCancelFullScreen) {
|
|
412
|
+
doc.mozCancelFullScreen();
|
|
413
|
+
} else if (doc.webkitExitFullscreen) {
|
|
414
|
+
doc.webkitExitFullscreen();
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
private isFullscreen() {
|
|
420
|
+
const doc = document as any;
|
|
421
|
+
|
|
422
|
+
return doc.fullscreenElement || doc.webkitFullscreenElement
|
|
423
|
+
|| doc.mozFullScreenElement || doc.msFullscreenElement;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
|
|
427
|
+
private show(first = false) {
|
|
428
|
+
this.loading = true;
|
|
429
|
+
this.stopAutoPlay();
|
|
430
|
+
|
|
431
|
+
this.activeChange.emit(this.index);
|
|
432
|
+
|
|
433
|
+
if (first || !this.animation) {
|
|
434
|
+
this._show();
|
|
435
|
+
} else {
|
|
436
|
+
setTimeout(() => this._show(), 600);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
private _show() {
|
|
441
|
+
this.zoomValue = 1;
|
|
442
|
+
this.rotateValue = 0;
|
|
443
|
+
this.resetPosition();
|
|
444
|
+
|
|
445
|
+
this.src = this.getSafeUrl(this.images[this.index] as string);
|
|
446
|
+
this.type = this.getFileType(this.images[this.index] as string);
|
|
447
|
+
this.srcIndex = this.index;
|
|
448
|
+
this.description = this.descriptions[this.index];
|
|
449
|
+
this.changeDetectorRef.markForCheck();
|
|
450
|
+
|
|
451
|
+
setTimeout(() => {
|
|
452
|
+
if (this.isLoaded(this.previewImage.nativeElement) || this.type === 'video') {
|
|
453
|
+
this.loading = false;
|
|
454
|
+
this.startAutoPlay();
|
|
455
|
+
this.changeDetectorRef.markForCheck();
|
|
456
|
+
} else if (this.type === 'video') {
|
|
457
|
+
|
|
458
|
+
}
|
|
459
|
+
else {
|
|
460
|
+
setTimeout(() => {
|
|
461
|
+
if (this.loading) {
|
|
462
|
+
this.showSpinner = true;
|
|
463
|
+
this.changeDetectorRef.markForCheck();
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
this.previewImage.nativeElement.onload = () => {
|
|
468
|
+
this.loading = false;
|
|
469
|
+
this.showSpinner = false;
|
|
470
|
+
this.previewImage.nativeElement.onload = null;
|
|
471
|
+
this.startAutoPlay();
|
|
472
|
+
this.changeDetectorRef.markForCheck();
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
private isLoaded(img): boolean {
|
|
479
|
+
if (!img.complete) {
|
|
480
|
+
return false;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
return !(typeof img.naturalWidth !== 'undefined' && img.naturalWidth === 0);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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" [ngClass]="{ 'ngx-gallery-active': i === selectedIndex, 'ngx-gallery-clickable': clickable }"
|
|
18
|
+
style="width: 100%; height: 100%; position:absolute; left:0; background:#000;">
|
|
19
|
+
<source [src]="image">
|
|
20
|
+
Your browser does not support the video tag.
|
|
21
|
+
</video>
|
|
22
|
+
</div>
|
|
23
|
+
}
|
|
24
|
+
<div class="ngx-gallery-icons-wrapper">
|
|
25
|
+
@for (action of actions; track action) {
|
|
26
|
+
<ngx-gallery-action [icon]="action.icon" [disabled]="action.disabled"
|
|
27
|
+
[titleText]="action.titleText" (closeClick)="action.onClick($event, i)"></ngx-gallery-action>
|
|
28
|
+
}
|
|
29
|
+
</div>
|
|
30
|
+
@if (remainingCount && remainingCountValue && (i === (rows * columns) - 1)) {
|
|
31
|
+
<div class="ngx-gallery-remaining-count-overlay"
|
|
32
|
+
>
|
|
33
|
+
<span class="ngx-gallery-remaining-count">+{{remainingCountValue}}</span>
|
|
34
|
+
</div>
|
|
35
|
+
}
|
|
36
|
+
</a>
|
|
37
|
+
}
|
|
38
|
+
</div>
|
|
39
|
+
</div>
|
|
40
|
+
@if (canShowArrows()) {
|
|
41
|
+
<ngx-gallery-arrows (prevClick)="moveLeft()" (nextClick)="moveRight()"
|
|
42
|
+
[prevDisabled]="!canMoveLeft()" [nextDisabled]="!canMoveRight()" [arrowPrevIcon]="arrowPrevIcon"
|
|
43
|
+
[arrowNextIcon]="arrowNextIcon"></ngx-gallery-arrows>
|
|
44
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
width: 100%;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
position: relative;
|
|
5
|
+
font-size: 25px;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.ngx-gallery-thumbnails-wrapper {
|
|
9
|
+
width: 100%;
|
|
10
|
+
height: 100%;
|
|
11
|
+
position: absolute;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.ngx-gallery-thumbnails {
|
|
16
|
+
height: 100%;
|
|
17
|
+
width: 100%;
|
|
18
|
+
position: absolute;
|
|
19
|
+
left: 0;
|
|
20
|
+
transform: translateX(0);
|
|
21
|
+
transition: transform 0.5s ease-in-out;
|
|
22
|
+
will-change: transform;
|
|
23
|
+
|
|
24
|
+
.ngx-gallery-thumbnail {
|
|
25
|
+
position: absolute;
|
|
26
|
+
height: 100%;
|
|
27
|
+
background-position: center;
|
|
28
|
+
background-repeat: no-repeat;
|
|
29
|
+
text-decoration: none;
|
|
30
|
+
border: 1px double black; /* Параметры границы */
|
|
31
|
+
// background: #fc3; /* Цвет фона */
|
|
32
|
+
// padding: 10px; /* Поля вокруг текста */
|
|
33
|
+
.ngx-gallery-thumbnail-video::after {
|
|
34
|
+
content: "\f144";
|
|
35
|
+
display: block;
|
|
36
|
+
position: absolute;
|
|
37
|
+
background: #0000;
|
|
38
|
+
height: 100%;
|
|
39
|
+
width: 100%;
|
|
40
|
+
left: 0;
|
|
41
|
+
top: calc(50% - 20px);
|
|
42
|
+
font-size: 40px;
|
|
43
|
+
color: white;
|
|
44
|
+
margin: 0;
|
|
45
|
+
padding: 0;
|
|
46
|
+
font-family: fontawesome;
|
|
47
|
+
text-shadow: 0px 4px 3px rgba(0,0,0,0.4), 0px 8px 13px rgba(0,0,0,0.1), 0px 18px 23px rgba(0,0,0,0.1);
|
|
48
|
+
}
|
|
49
|
+
.img {
|
|
50
|
+
/* background-position: center;
|
|
51
|
+
background-repeat: no-repeat;
|
|
52
|
+
text-decoration: none;*/
|
|
53
|
+
background-size: cover;
|
|
54
|
+
// width: 100%;
|
|
55
|
+
height: 100%;
|
|
56
|
+
}
|
|
57
|
+
&.ngx-gallery-active {
|
|
58
|
+
border: 1px double #cc4548;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.ngx-gallery-thumbnail-size-cover .ngx-gallery-thumbnails .ngx-gallery-thumbnail {
|
|
64
|
+
background-size: cover;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.ngx-gallery-thumbnail-size-contain .ngx-gallery-thumbnails .ngx-gallery-thumbnail {
|
|
68
|
+
background-size: contain;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.ngx-gallery-remaining-count-overlay {
|
|
72
|
+
width: 100%;
|
|
73
|
+
height: 100%;
|
|
74
|
+
position: absolute;
|
|
75
|
+
left: 0;
|
|
76
|
+
top: 0;
|
|
77
|
+
background-color: rgba(0, 0, 0, .4);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.ngx-gallery-remaining-count {
|
|
81
|
+
position: absolute;
|
|
82
|
+
top: 50%;
|
|
83
|
+
left: 50%;
|
|
84
|
+
transform: translate(-50%, -50%);
|
|
85
|
+
color: white;
|
|
86
|
+
font-size: 30px;
|
|
87
|
+
}
|
package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.spec.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
2
|
+
|
|
3
|
+
import { NgxGalleryThumbnailsComponent } from './ngx-gallery-thumbnails.component';
|
|
4
|
+
import {NgxGalleryActionComponent} from '../ngx-gallery-action/ngx-gallery-action.component';
|
|
5
|
+
import {NgxGalleryArrowsComponent} from '../ngx-gallery-arrows/ngx-gallery-arrows.component';
|
|
6
|
+
import {Renderer2} from '@angular/core';
|
|
7
|
+
import {NgxGalleryService} from '../ngx-gallery.service';
|
|
8
|
+
|
|
9
|
+
describe('NgxGalleryThumbnailsComponent', () => {
|
|
10
|
+
let component: NgxGalleryThumbnailsComponent;
|
|
11
|
+
let fixture: ComponentFixture<NgxGalleryThumbnailsComponent>;
|
|
12
|
+
|
|
13
|
+
beforeEach(async(() => {
|
|
14
|
+
TestBed.configureTestingModule({
|
|
15
|
+
declarations: [ NgxGalleryThumbnailsComponent, NgxGalleryActionComponent, NgxGalleryArrowsComponent ],
|
|
16
|
+
imports: [],
|
|
17
|
+
providers: [Renderer2, NgxGalleryService]
|
|
18
|
+
})
|
|
19
|
+
.compileComponents();
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
fixture = TestBed.createComponent(NgxGalleryThumbnailsComponent);
|
|
24
|
+
component = fixture.componentInstance;
|
|
25
|
+
fixture.detectChanges();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should create', () => {
|
|
29
|
+
expect(component).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
});
|