@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.
Files changed (106) hide show
  1. package/.editorconfig +13 -0
  2. package/.eslintrc.json +51 -0
  3. package/.travis.yml +38 -0
  4. package/angular.json +108 -0
  5. package/package.json +64 -37
  6. package/projects/gallery/.eslintrc.json +55 -0
  7. package/projects/gallery/README.md +24 -0
  8. package/projects/gallery/karma.conf.js +52 -0
  9. package/projects/gallery/ng-package.json +7 -0
  10. package/projects/gallery/package.json +32 -0
  11. package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.html +4 -0
  12. package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.scss +21 -0
  13. package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.spec.ts +25 -0
  14. package/projects/gallery/src/lib/ngx-gallery-action/ngx-gallery-action.component.ts +28 -0
  15. package/projects/gallery/src/lib/ngx-gallery-action.ts +23 -0
  16. package/projects/gallery/src/lib/ngx-gallery-animation.ts +6 -0
  17. package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.html +27 -0
  18. package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.scss +45 -0
  19. package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.spec.ts +25 -0
  20. package/projects/gallery/src/lib/ngx-gallery-arrows/ngx-gallery-arrows.component.ts +28 -0
  21. package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.html +4 -0
  22. package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.scss +26 -0
  23. package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.spec.ts +25 -0
  24. package/projects/gallery/src/lib/ngx-gallery-bullets/ngx-gallery-bullets.component.ts +25 -0
  25. package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.html +49 -0
  26. package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.scss +106 -0
  27. package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.spec.ts +35 -0
  28. package/projects/gallery/src/lib/ngx-gallery-image/ngx-gallery-image.component.ts +381 -0
  29. package/projects/gallery/src/lib/ngx-gallery-image-size.ts +4 -0
  30. package/projects/gallery/src/lib/ngx-gallery-image.ts +31 -0
  31. package/projects/gallery/src/lib/ngx-gallery-layout.ts +4 -0
  32. package/projects/gallery/src/lib/ngx-gallery-options.ts +261 -0
  33. package/projects/gallery/src/lib/ngx-gallery-order.ts +5 -0
  34. package/projects/gallery/src/lib/ngx-gallery-ordered-image.ts +19 -0
  35. package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.html +117 -0
  36. package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.scss +121 -0
  37. package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.spec.ts +34 -0
  38. package/projects/gallery/src/lib/ngx-gallery-preview/ngx-gallery-preview.component.ts +619 -0
  39. package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.html +45 -0
  40. package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.scss +87 -0
  41. package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.spec.ts +31 -0
  42. package/projects/gallery/src/lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component.ts +298 -0
  43. package/projects/gallery/src/lib/ngx-gallery.component.html +53 -0
  44. package/projects/gallery/src/lib/ngx-gallery.component.scss +77 -0
  45. package/projects/gallery/src/lib/ngx-gallery.component.spec.ts +37 -0
  46. package/projects/gallery/src/lib/ngx-gallery.component.ts +336 -0
  47. package/projects/gallery/src/lib/ngx-gallery.module.ts +29 -0
  48. package/projects/gallery/src/lib/ngx-gallery.service.spec.ts +18 -0
  49. package/projects/gallery/src/lib/ngx-gallery.service.ts +71 -0
  50. package/projects/gallery/src/public-api.ts +20 -0
  51. package/projects/gallery/src/test.ts +17 -0
  52. package/projects/gallery/tsconfig.lib.json +14 -0
  53. package/projects/gallery/tsconfig.lib.prod.json +9 -0
  54. package/projects/gallery/tsconfig.spec.json +16 -0
  55. package/projects/gallery-app/.browserslistrc +12 -0
  56. package/projects/gallery-app/.eslintrc.json +40 -0
  57. package/projects/gallery-app/e2e/protractor.conf.js +32 -0
  58. package/projects/gallery-app/e2e/src/app.e2e-spec.ts +23 -0
  59. package/projects/gallery-app/e2e/src/app.po.ts +11 -0
  60. package/projects/gallery-app/e2e/tsconfig.json +13 -0
  61. package/projects/gallery-app/karma.conf.js +32 -0
  62. package/projects/gallery-app/src/app/app-routing.module.ts +11 -0
  63. package/projects/gallery-app/src/app/app.component.html +4 -0
  64. package/projects/gallery-app/src/app/app.component.scss +9 -0
  65. package/projects/gallery-app/src/app/app.component.spec.ts +35 -0
  66. package/projects/gallery-app/src/app/app.component.ts +82 -0
  67. package/projects/gallery-app/src/app/app.module.ts +20 -0
  68. package/projects/gallery-app/src/assets/.gitkeep +0 -0
  69. package/projects/gallery-app/src/assets/img/gallery/1-big.jpeg +0 -0
  70. package/projects/gallery-app/src/assets/img/gallery/1-medium.jpeg +0 -0
  71. package/projects/gallery-app/src/assets/img/gallery/1-small.jpeg +0 -0
  72. package/projects/gallery-app/src/assets/img/gallery/2-big.jpeg +0 -0
  73. package/projects/gallery-app/src/assets/img/gallery/2-medium.jpeg +0 -0
  74. package/projects/gallery-app/src/assets/img/gallery/2-small.jpeg +0 -0
  75. package/projects/gallery-app/src/assets/img/gallery/3-big.jpeg +0 -0
  76. package/projects/gallery-app/src/assets/img/gallery/3-medium.jpeg +0 -0
  77. package/projects/gallery-app/src/assets/img/gallery/3-small.jpeg +0 -0
  78. package/projects/gallery-app/src/assets/img/gallery/4-big.jpeg +0 -0
  79. package/projects/gallery-app/src/assets/img/gallery/4-medium.jpeg +0 -0
  80. package/projects/gallery-app/src/assets/img/gallery/4-small.jpeg +0 -0
  81. package/projects/gallery-app/src/assets/img/gallery/5-big.jpeg +0 -0
  82. package/projects/gallery-app/src/assets/img/gallery/5-medium.jpeg +0 -0
  83. package/projects/gallery-app/src/assets/img/gallery/5-small.jpeg +0 -0
  84. package/projects/gallery-app/src/assets/img/gallery/6-big.jpeg +0 -0
  85. package/projects/gallery-app/src/assets/img/gallery/6-medium.jpeg +0 -0
  86. package/projects/gallery-app/src/assets/img/gallery/6-small.jpeg +0 -0
  87. package/projects/gallery-app/src/assets/img/gallery/7-big.jpeg +0 -0
  88. package/projects/gallery-app/src/assets/img/gallery/7-medium.jpeg +0 -0
  89. package/projects/gallery-app/src/assets/img/gallery/7-small.jpeg +0 -0
  90. package/projects/gallery-app/src/assets/img/gallery/8-big.jpeg +0 -0
  91. package/projects/gallery-app/src/assets/img/gallery/8-medium.jpeg +0 -0
  92. package/projects/gallery-app/src/assets/img/gallery/8-small.jpeg +0 -0
  93. package/projects/gallery-app/src/environments/environment.prod.ts +3 -0
  94. package/projects/gallery-app/src/environments/environment.ts +16 -0
  95. package/projects/gallery-app/src/favicon.ico +0 -0
  96. package/projects/gallery-app/src/index.html +13 -0
  97. package/projects/gallery-app/src/main.ts +12 -0
  98. package/projects/gallery-app/src/polyfills.ts +53 -0
  99. package/projects/gallery-app/src/styles.scss +1 -0
  100. package/projects/gallery-app/src/test.ts +16 -0
  101. package/projects/gallery-app/tsconfig.app.json +17 -0
  102. package/projects/gallery-app/tsconfig.spec.json +18 -0
  103. package/tsconfig.json +43 -0
  104. package/fesm2022/autotaxatiepartners-ngx-gallery.mjs +0 -1756
  105. package/fesm2022/autotaxatiepartners-ngx-gallery.mjs.map +0 -1
  106. package/index.d.ts +0 -591
@@ -0,0 +1,336 @@
1
+ import {
2
+ AfterViewInit,
3
+ ChangeDetectionStrategy,
4
+ Component,
5
+ DoCheck,
6
+ ElementRef,
7
+ EventEmitter,
8
+ HostBinding,
9
+ HostListener,
10
+ Input,
11
+ OnInit,
12
+ Output,
13
+ ViewChild,
14
+ ViewEncapsulation
15
+ } from '@angular/core';
16
+ import {NgxGalleryPreviewComponent} from './ngx-gallery-preview/ngx-gallery-preview.component';
17
+ import {NgxGalleryImageComponent} from './ngx-gallery-image/ngx-gallery-image.component';
18
+ import {NgxGalleryThumbnailsComponent} from './ngx-gallery-thumbnails/ngx-gallery-thumbnails.component';
19
+ import {SafeResourceUrl} from '@angular/platform-browser';
20
+ import {NgxGalleryService} from './ngx-gallery.service';
21
+ import {NgxGalleryOptions} from './ngx-gallery-options';
22
+ import {NgxGalleryImage} from './ngx-gallery-image';
23
+ import {NgxGalleryOrderedImage} from './ngx-gallery-ordered-image';
24
+ import {NgxGalleryLayout} from './ngx-gallery-layout';
25
+
26
+ @Component({
27
+ selector: 'ngx-gallery',
28
+ templateUrl: './ngx-gallery.component.html',
29
+ styleUrls: ['./ngx-gallery.component.scss'],
30
+ encapsulation: ViewEncapsulation.None,
31
+ providers: [NgxGalleryService],
32
+ changeDetection: ChangeDetectionStrategy.OnPush,
33
+ standalone: false
34
+ })
35
+ export class NgxGalleryComponent implements OnInit, DoCheck, AfterViewInit {
36
+ @Input() options: NgxGalleryOptions[] = [{}];
37
+ @Input() images: NgxGalleryImage[];
38
+
39
+ @Output() imagesReady = new EventEmitter();
40
+ @Output() change = new EventEmitter<{ index: number; image: NgxGalleryImage; }>();
41
+ @Output() previewOpen = new EventEmitter();
42
+ @Output() previewClose = new EventEmitter();
43
+ @Output() previewChange = new EventEmitter<{ index: number; image: NgxGalleryImage; }>();
44
+
45
+ smallImages: string[] | SafeResourceUrl[];
46
+ mediumImages: NgxGalleryOrderedImage[];
47
+ bigImages: string[] | SafeResourceUrl[];
48
+ descriptions: string[];
49
+ links: string[];
50
+ labels: string[];
51
+
52
+ oldImages: NgxGalleryImage[];
53
+ oldImagesLength = 0;
54
+
55
+ selectedIndex = 0;
56
+ isAnimating: boolean;
57
+ previewEnabled: boolean;
58
+
59
+ currentOptions: NgxGalleryOptions;
60
+
61
+ private breakpoint: number | undefined = undefined;
62
+ private prevBreakpoint: number | undefined = undefined;
63
+ private fullWidthTimeout: any;
64
+
65
+ @ViewChild(NgxGalleryPreviewComponent) preview: NgxGalleryPreviewComponent;
66
+ @ViewChild(NgxGalleryImageComponent) image: NgxGalleryImageComponent;
67
+ @ViewChild(NgxGalleryThumbnailsComponent) thumbnails: NgxGalleryThumbnailsComponent;
68
+
69
+ @HostBinding('style.width') width: string;
70
+ @HostBinding('style.height') height: string;
71
+ @HostBinding('style.transform') left: string;
72
+
73
+ constructor(private myElement: ElementRef, private helperService: NgxGalleryService) {
74
+ }
75
+
76
+ ngOnInit() {
77
+ this.options = this.options.map((opt) => new NgxGalleryOptions(opt));
78
+ this.sortOptions();
79
+ this.setBreakpoint();
80
+ this.setOptions();
81
+ this.checkFullWidth();
82
+ if (this.currentOptions) {
83
+ this.selectedIndex = this.currentOptions.startIndex as number;
84
+ }
85
+ }
86
+
87
+ ngDoCheck(): void {
88
+ if (this.images !== undefined && (this.images.length !== this.oldImagesLength)
89
+ || (this.images !== this.oldImages)) {
90
+ this.oldImagesLength = this.images.length;
91
+ this.oldImages = this.images;
92
+ this.setOptions();
93
+ this.setImages();
94
+
95
+ if (this.images && this.images.length) {
96
+ this.imagesReady.emit();
97
+ }
98
+
99
+ if (this.image) {
100
+ this.image.reset(this.currentOptions.startIndex as number);
101
+ }
102
+
103
+ if (this.currentOptions.thumbnailsAutoHide && this.currentOptions.thumbnails
104
+ && this.images.length <= 1) {
105
+ this.currentOptions.thumbnails = false;
106
+ this.currentOptions.imageArrows = false;
107
+ }
108
+
109
+ this.resetThumbnails();
110
+ }
111
+ }
112
+
113
+ ngAfterViewInit(): void {
114
+ this.checkFullWidth();
115
+ }
116
+
117
+ @HostListener('window:resize') onResize() {
118
+ this.setBreakpoint();
119
+
120
+ if (this.prevBreakpoint !== this.breakpoint) {
121
+ this.setOptions();
122
+ this.resetThumbnails();
123
+ }
124
+
125
+ if (this.currentOptions && this.currentOptions.fullWidth) {
126
+
127
+ if (this.fullWidthTimeout) {
128
+ clearTimeout(this.fullWidthTimeout);
129
+ }
130
+
131
+ this.fullWidthTimeout = setTimeout(() => {
132
+ this.checkFullWidth();
133
+ }, 200);
134
+ }
135
+ }
136
+
137
+ getImageHeight(): string {
138
+ return (this.currentOptions && this.currentOptions.thumbnails) ?
139
+ this.currentOptions.imagePercent + '%' : '100%';
140
+ }
141
+
142
+ getThumbnailsHeight(): string {
143
+ if (this.currentOptions && this.currentOptions.image) {
144
+ return 'calc(' + this.currentOptions.thumbnailsPercent + '% - '
145
+ + this.currentOptions.thumbnailsMargin + 'px)';
146
+ } else {
147
+ return '100%';
148
+ }
149
+ }
150
+
151
+ getThumbnailsMarginTop(): string {
152
+ if (this.currentOptions && this.currentOptions.layout === NgxGalleryLayout.ThumbnailsBottom) {
153
+ return this.currentOptions.thumbnailsMargin + 'px';
154
+ } else {
155
+ return '0px';
156
+ }
157
+ }
158
+
159
+ getThumbnailsMarginBottom(): string {
160
+ if (this.currentOptions && this.currentOptions.layout === NgxGalleryLayout.ThumbnailsTop) {
161
+ return this.currentOptions.thumbnailsMargin + 'px';
162
+ } else {
163
+ return '0px';
164
+ }
165
+ }
166
+
167
+ openPreview(index: number): void {
168
+ if (this.currentOptions.previewCustom) {
169
+ this.currentOptions.previewCustom(index);
170
+ } else {
171
+ this.previewEnabled = true;
172
+ this.preview.open(index);
173
+ }
174
+ }
175
+
176
+ onPreviewOpen(): void {
177
+ this.previewOpen.emit();
178
+
179
+ if (this.image && this.image.autoPlay) {
180
+ this.image.stopAutoPlay();
181
+ }
182
+ }
183
+
184
+ onPreviewClose(): void {
185
+ this.previewEnabled = false;
186
+ this.previewClose.emit();
187
+
188
+ if (this.image && this.image.autoPlay) {
189
+ this.image.startAutoPlay();
190
+ }
191
+ }
192
+
193
+ selectFromImage(index: number) {
194
+ this.select(index);
195
+ }
196
+
197
+ selectFromThumbnails(index: number) {
198
+ this.select(index);
199
+
200
+ if (this.currentOptions && this.currentOptions.thumbnails && this.currentOptions.preview
201
+ && (!this.currentOptions.image || this.currentOptions.thumbnailsRemainingCount)) {
202
+ this.openPreview(this.selectedIndex);
203
+ }
204
+ }
205
+
206
+ show(index: number): void {
207
+ this.select(index);
208
+ }
209
+
210
+ showNext(): void {
211
+ this.image.showNext();
212
+ }
213
+
214
+ showPrev(): void {
215
+ this.image.showPrev();
216
+ }
217
+
218
+ canShowNext(): boolean {
219
+ if (this.images && this.currentOptions) {
220
+ return !!(this.currentOptions.imageInfinityMove || this.selectedIndex < this.images.length - 1);
221
+ } else {
222
+ return false;
223
+ }
224
+ }
225
+
226
+ canShowPrev(): boolean {
227
+ if (this.images && this.currentOptions) {
228
+ return !!(this.currentOptions.imageInfinityMove || this.selectedIndex > 0);
229
+ } else {
230
+ return false;
231
+ }
232
+ }
233
+
234
+ previewSelect(index: number) {
235
+ this.previewChange.emit({index, image: this.images[index]});
236
+ }
237
+
238
+ moveThumbnailsRight() {
239
+ this.thumbnails.moveRight();
240
+ }
241
+
242
+ moveThumbnailsLeft() {
243
+ this.thumbnails.moveLeft();
244
+ }
245
+
246
+ canMoveThumbnailsRight() {
247
+ return this.thumbnails.canMoveRight();
248
+ }
249
+
250
+ canMoveThumbnailsLeft() {
251
+ return this.thumbnails.canMoveLeft();
252
+ }
253
+
254
+ private resetThumbnails() {
255
+ if (this.thumbnails) {
256
+ this.thumbnails.reset(this.currentOptions.startIndex as number);
257
+ }
258
+ }
259
+
260
+ private select(index: number) {
261
+ this.selectedIndex = index;
262
+
263
+ this.change.emit({
264
+ index,
265
+ image: this.images[index]
266
+ });
267
+ }
268
+
269
+ private checkFullWidth(): void {
270
+ if (this.currentOptions && this.currentOptions.fullWidth) {
271
+ this.width = document.body.clientWidth + 'px';
272
+ this.left = 'translateX(' + (-(document.body.clientWidth -
273
+ this.myElement.nativeElement.parentNode.innerWidth) / 2) + 'px)';
274
+ }
275
+ }
276
+
277
+ private setImages(): void {
278
+ this.images.forEach((img) =>
279
+ img.type = this.helperService.getFileType(img.url as string || img.big as string || img.medium as string || img.small as string || '')
280
+ );
281
+ this.smallImages = this.images.map((img) => img.small as string);
282
+ this.mediumImages = this.images.map((img, i) => new NgxGalleryOrderedImage({
283
+ src: img.medium,
284
+ type: img.type,
285
+ index: i
286
+ }));
287
+ this.bigImages = this.images.map((img) => img.big as string);
288
+ this.descriptions = this.images.map((img) => img.description as string);
289
+ this.links = this.images.map((img) => img.url as string);
290
+ this.labels = this.images.map((img) => img.label as string);
291
+ }
292
+
293
+ private setBreakpoint(): void {
294
+ this.prevBreakpoint = this.breakpoint;
295
+ let breakpoints;
296
+
297
+ if (typeof window !== 'undefined') {
298
+ breakpoints = this.options.filter((opt) => opt.breakpoint >= window.innerWidth)
299
+ .map((opt) => opt.breakpoint);
300
+ }
301
+
302
+ if (breakpoints && breakpoints.length) {
303
+ this.breakpoint = breakpoints.pop();
304
+ } else {
305
+ this.breakpoint = undefined;
306
+ }
307
+ }
308
+
309
+ private sortOptions(): void {
310
+ this.options = [
311
+ ...this.options.filter((a) => a.breakpoint === undefined),
312
+ ...this.options
313
+ .filter((a) => a.breakpoint !== undefined)
314
+ .sort((a, b) => b.breakpoint - a.breakpoint)
315
+ ];
316
+ }
317
+
318
+ private setOptions(): void {
319
+ this.currentOptions = new NgxGalleryOptions({});
320
+
321
+ this.options
322
+ .filter((opt) => opt.breakpoint === undefined || opt.breakpoint >= this.breakpoint)
323
+ .map((opt) => this.combineOptions(this.currentOptions, opt));
324
+
325
+ this.width = this.currentOptions.width as string;
326
+ this.height = this.currentOptions.height as string;
327
+ }
328
+
329
+ private combineOptions(first: NgxGalleryOptions, second: NgxGalleryOptions) {
330
+ Object.keys(second).map((val) => first[val] = second[val] !== undefined ? second[val] : first[val]);
331
+ }
332
+
333
+ setAnimating(event: boolean) {
334
+ this.isAnimating = event;
335
+ }
336
+ }
@@ -0,0 +1,29 @@
1
+ import { NgModule, Injectable } from '@angular/core';
2
+ import { NgxGalleryComponent } from './ngx-gallery.component';
3
+ import { NgxGalleryImageComponent } from './ngx-gallery-image/ngx-gallery-image.component';
4
+ import { NgxGalleryArrowsComponent } from './ngx-gallery-arrows/ngx-gallery-arrows.component';
5
+ import { NgxGalleryThumbnailsComponent } from './ngx-gallery-thumbnails/ngx-gallery-thumbnails.component';
6
+ import { NgxGalleryPreviewComponent } from './ngx-gallery-preview/ngx-gallery-preview.component';
7
+ import { NgxGalleryActionComponent } from './ngx-gallery-action/ngx-gallery-action.component';
8
+ import { NgxGalleryBulletsComponent } from './ngx-gallery-bullets/ngx-gallery-bullets.component';
9
+ import { CommonModule } from '@angular/common';
10
+
11
+ @Injectable()
12
+ @NgModule({
13
+ declarations: [
14
+ NgxGalleryComponent,
15
+ NgxGalleryImageComponent,
16
+ NgxGalleryArrowsComponent,
17
+ NgxGalleryThumbnailsComponent,
18
+ NgxGalleryPreviewComponent,
19
+ NgxGalleryActionComponent,
20
+ NgxGalleryBulletsComponent
21
+ ],
22
+ imports: [CommonModule],
23
+ exports: [NgxGalleryComponent],
24
+ providers: [
25
+
26
+ ]
27
+ })
28
+ export class NgxGalleryModule {
29
+ }
@@ -0,0 +1,18 @@
1
+ import {inject, TestBed} from '@angular/core/testing';
2
+
3
+ import { NgxGalleryService } from './ngx-gallery.service';
4
+ import { provideHttpClient, withInterceptorsFromDi } from '@angular/common/http';
5
+ import {Renderer2} from '@angular/core';
6
+
7
+ describe('NgxGalleryService', () => {
8
+ beforeEach(() => {
9
+ TestBed.configureTestingModule({
10
+ imports: [],
11
+ providers: [NgxGalleryService, Renderer2, provideHttpClient(withInterceptorsFromDi())]
12
+ });
13
+ });
14
+
15
+ it('should be created', inject([NgxGalleryService], (service: NgxGalleryService) => {
16
+ expect(service).toBeTruthy();
17
+ }));
18
+ });
@@ -0,0 +1,71 @@
1
+ import { ElementRef, Injectable, Renderer2 } from '@angular/core';
2
+
3
+ @Injectable({ providedIn: 'root' })
4
+ export class NgxGalleryService {
5
+ private swipeHandlers: Map<string, (() => void)[]> = new Map();
6
+ private pointerData: Map<string, { x: number }> = new Map();
7
+
8
+ constructor(private renderer: Renderer2) {}
9
+
10
+ manageSwipe(
11
+ status: boolean,
12
+ element: ElementRef,
13
+ id: string,
14
+ nextHandler: () => void,
15
+ prevHandler: () => void
16
+ ): void {
17
+ const handlers = this.swipeHandlers.get(id);
18
+
19
+ if (status && !handlers) {
20
+ const el = element.nativeElement;
21
+
22
+ const pointerDown = this.renderer.listen(el, 'pointerdown', (event: PointerEvent) => {
23
+ this.pointerData.set(id, { x: event.clientX });
24
+ });
25
+
26
+ const pointerUp = this.renderer.listen(el, 'pointerup', (event: PointerEvent) => {
27
+ const start = this.pointerData.get(id);
28
+ const endX = event.clientX;
29
+
30
+ if (!start) return;
31
+
32
+ const deltaX = endX - start.x;
33
+ const threshold = 40;
34
+
35
+ if (deltaX > threshold) {
36
+ prevHandler();
37
+ } else if (deltaX < -threshold) {
38
+ nextHandler();
39
+ }
40
+
41
+ this.pointerData.delete(id);
42
+ });
43
+
44
+ const pointerCancel = this.renderer.listen(el, 'pointercancel', () => {
45
+ this.pointerData.delete(id);
46
+ });
47
+
48
+ const pointerLeave = this.renderer.listen(el, 'pointerleave', () => {
49
+ this.pointerData.delete(id);
50
+ });
51
+
52
+ this.swipeHandlers.set(id, [pointerDown, pointerUp, pointerCancel, pointerLeave]);
53
+ } else if (!status && handlers) {
54
+ handlers.forEach(unlisten => unlisten());
55
+ this.swipeHandlers.delete(id);
56
+ }
57
+ }
58
+
59
+ validateUrl(url: string): string {
60
+ return url?.replace(/ /g, '%20').replace(/'/g, '%27') ?? url;
61
+ }
62
+
63
+ getBackgroundUrl(image: string): string {
64
+ return `url('${this.validateUrl(image)}')`;
65
+ }
66
+
67
+ getFileType(fileSource: string): string {
68
+ const ext = fileSource.split('.').pop()?.toLowerCase();
69
+ return ['avi', 'flv', 'wmv', 'mov', 'mp4'].includes(ext ?? '') ? 'video' : 'image';
70
+ }
71
+ }
@@ -0,0 +1,20 @@
1
+ /*
2
+ * Public API Surface of ngx-gallery
3
+ */
4
+
5
+ export * from './lib/ngx-gallery.service';
6
+ export * from './lib/ngx-gallery.component';
7
+ export * from './lib/ngx-gallery.module';
8
+ export * from './lib/ngx-gallery-action';
9
+ export * from './lib/ngx-gallery-image';
10
+ export * from './lib/ngx-gallery-thumbnails/ngx-gallery-thumbnails.component';
11
+ export * from './lib/ngx-gallery-preview/ngx-gallery-preview.component';
12
+ export * from './lib/ngx-gallery-arrows/ngx-gallery-arrows.component';
13
+ export * from './lib/ngx-gallery-bullets/ngx-gallery-bullets.component';
14
+ export * from './lib/ngx-gallery-options';
15
+ export * from './lib/ngx-gallery-image';
16
+ export * from './lib/ngx-gallery-animation';
17
+ export * from './lib/ngx-gallery-image-size';
18
+ export * from './lib/ngx-gallery-layout';
19
+ export * from './lib/ngx-gallery-order';
20
+ export * from './lib/ngx-gallery-ordered-image';
@@ -0,0 +1,17 @@
1
+ // This file is required by karma.conf.js and loads recursively all the .spec and framework files
2
+
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { getTestBed } from '@angular/core/testing';
6
+ import {
7
+ BrowserDynamicTestingModule,
8
+ platformBrowserDynamicTesting
9
+ } from '@angular/platform-browser-dynamic/testing';
10
+
11
+ // First, initialize the Angular testing environment.
12
+ getTestBed().initTestEnvironment(
13
+ BrowserDynamicTestingModule,
14
+ platformBrowserDynamicTesting(), {
15
+ teardown: { destroyAfterEach: false }
16
+ }
17
+ );
@@ -0,0 +1,14 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../out-tsc/lib",
5
+ "declarationMap": true,
6
+ "declaration": true,
7
+ "inlineSources": true,
8
+ "types": []
9
+ },
10
+ "exclude": [
11
+ "src/test.ts",
12
+ "**/*.spec.ts"
13
+ ]
14
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.lib.json",
3
+ "compilerOptions": {
4
+ "declarationMap": false
5
+ },
6
+ "angularCompilerOptions": {
7
+ "compilationMode": "partial"
8
+ }
9
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../out-tsc/spec",
5
+ "types": [
6
+ "jasmine"
7
+ ]
8
+ },
9
+ "files": [
10
+ "src/test.ts"
11
+ ],
12
+ "include": [
13
+ "**/*.spec.ts",
14
+ "**/*.d.ts"
15
+ ]
16
+ }
@@ -0,0 +1,12 @@
1
+ # This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2
+ # For additional information regarding the format and rule options, please see:
3
+ # https://github.com/browserslist/browserslist#queries
4
+
5
+ # You can see what browsers were selected by your queries by running:
6
+ # npx browserslist
7
+
8
+ > 0.5%
9
+ last 2 versions
10
+ Firefox ESR
11
+ not dead
12
+ not IE 9-11 # For IE 9-11 support, remove 'not'.
@@ -0,0 +1,40 @@
1
+ {
2
+ "extends": "../../.eslintrc.json",
3
+ "ignorePatterns": [
4
+ "!**/*"
5
+ ],
6
+ "overrides": [
7
+ {
8
+ "files": [
9
+ "*.ts"
10
+ ],
11
+ "parserOptions": {
12
+ "project": [
13
+ "projects/gallery-app/tsconfig.app.json",
14
+ "projects/gallery-app/tsconfig.spec.json",
15
+ "projects/gallery-app/e2e/tsconfig.json"
16
+ ],
17
+ "createDefaultProgram": true
18
+ },
19
+ "rules": {
20
+ "@typescript-eslint/explicit-member-accessibility": [
21
+ "off",
22
+ {
23
+ "accessibility": "explicit"
24
+ }
25
+ ],
26
+ "arrow-parens": [
27
+ "off",
28
+ "always"
29
+ ],
30
+ "import/order": "off"
31
+ }
32
+ },
33
+ {
34
+ "files": [
35
+ "*.html"
36
+ ],
37
+ "rules": {}
38
+ }
39
+ ]
40
+ }
@@ -0,0 +1,32 @@
1
+ // @ts-check
2
+ // Protractor configuration file, see link for more information
3
+ // https://github.com/angular/protractor/blob/master/lib/config.ts
4
+
5
+ const { SpecReporter } = require('jasmine-spec-reporter');
6
+
7
+ /**
8
+ * @type { import("protractor").Config }
9
+ */
10
+ exports.config = {
11
+ allScriptsTimeout: 11000,
12
+ specs: [
13
+ './src/**/*.e2e-spec.ts'
14
+ ],
15
+ capabilities: {
16
+ browserName: 'chrome'
17
+ },
18
+ directConnect: true,
19
+ baseUrl: 'http://localhost:4200/',
20
+ framework: 'jasmine',
21
+ jasmineNodeOpts: {
22
+ showColors: true,
23
+ defaultTimeoutInterval: 30000,
24
+ print: function() {}
25
+ },
26
+ onPrepare() {
27
+ require('ts-node').register({
28
+ project: require('path').join(__dirname, './tsconfig.json')
29
+ });
30
+ jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
31
+ }
32
+ };
@@ -0,0 +1,23 @@
1
+ import { AppPage } from './app.po';
2
+ import { browser, logging } from 'protractor';
3
+
4
+ describe('workspace-project App', () => {
5
+ let page: AppPage;
6
+
7
+ beforeEach(() => {
8
+ page = new AppPage();
9
+ });
10
+
11
+ it('should display welcome message', () => {
12
+ page.navigateTo();
13
+ expect(page.getTitleText()).toEqual('gallery-app app is running!');
14
+ });
15
+
16
+ afterEach(async () => {
17
+ // Assert that there are no errors emitted from the browser
18
+ const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19
+ expect(logs).not.toContain(jasmine.objectContaining({
20
+ level: logging.Level.SEVERE,
21
+ } as logging.Entry));
22
+ });
23
+ });
@@ -0,0 +1,11 @@
1
+ import { browser, by, element } from 'protractor';
2
+
3
+ export class AppPage {
4
+ navigateTo() {
5
+ return browser.get(browser.baseUrl) as Promise<any>;
6
+ }
7
+
8
+ getTitleText() {
9
+ return element(by.css('app-root .content span')).getText() as Promise<string>;
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "../../../out-tsc/e2e",
5
+ "module": "commonjs",
6
+ "target": "es2018",
7
+ "types": [
8
+ "jasmine",
9
+ "jasminewd2",
10
+ "node"
11
+ ]
12
+ }
13
+ }