nextalys-carousel 0.0.54 → 0.0.55
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/bundles/nextalys-carousel.umd.js +137 -273
- package/bundles/nextalys-carousel.umd.js.map +1 -1
- package/bundles/nextalys-carousel.umd.min.js +2 -2
- package/bundles/nextalys-carousel.umd.min.js.map +1 -1
- package/esm2015/lib/nxs-carousel/nxs-carousel-types.js +1 -1
- package/esm2015/lib/nxs-carousel/nxs-carousel.component.js +114 -218
- package/esm2015/lib/nxs-carousel/nxs-carousel.module.js +6 -3
- package/esm2015/lib/nxs-carousel/swiper-directives.js +9 -0
- package/esm2015/nextalys-carousel.js +3 -2
- package/fesm2015/nextalys-carousel.js +122 -220
- package/fesm2015/nextalys-carousel.js.map +1 -1
- package/lib/nxs-carousel/nxs-carousel-types.d.ts +2 -58
- package/lib/nxs-carousel/nxs-carousel-types.d.ts.map +1 -1
- package/lib/nxs-carousel/nxs-carousel.component.d.ts +15 -17
- package/lib/nxs-carousel/nxs-carousel.component.d.ts.map +1 -1
- package/lib/nxs-carousel/nxs-carousel.module.d.ts.map +1 -1
- package/lib/nxs-carousel/swiper-directives.d.ts +3 -0
- package/lib/nxs-carousel/swiper-directives.d.ts.map +1 -0
- package/nextalys-carousel.d.ts +2 -1
- package/nextalys-carousel.d.ts.map +1 -1
- package/nextalys-carousel.metadata.json +1 -1
- package/package.json +3 -13
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/material/dialog'), require('@angular/common'), require('nextalys-js-helpers/dist/events'), require('@angular/material/button'), require('@angular/material/icon'), require('
|
|
3
|
-
typeof define === 'function' && define.amd ? define('nextalys-carousel', ['exports', '@angular/core', '@angular/material/dialog', '@angular/common', 'nextalys-js-helpers/dist/events', '@angular/material/button', '@angular/material/icon', '
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['nextalys-carousel'] = {}, global.ng.core, global.ng.material.dialog, global.ng.common, global.events, global.ng.material.button, global.ng.material.icon, global.
|
|
5
|
-
}(this, (function (exports, core, dialog, common, events, button, icon,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/material/dialog'), require('@angular/common'), require('nextalys-js-helpers/dist/events'), require('swiper'), require('@angular/material/button'), require('@angular/material/icon'), require('swiper/angular')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define('nextalys-carousel', ['exports', '@angular/core', '@angular/material/dialog', '@angular/common', 'nextalys-js-helpers/dist/events', 'swiper', '@angular/material/button', '@angular/material/icon', 'swiper/angular'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['nextalys-carousel'] = {}, global.ng.core, global.ng.material.dialog, global.ng.common, global.events, global.swiper, global.ng.material.button, global.ng.material.icon, global.angular));
|
|
5
|
+
}(this, (function (exports, core, dialog, common, events, SwiperCore, button, icon, angular) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var SwiperCore__default = /*#__PURE__*/_interopDefaultLegacy(SwiperCore);
|
|
6
10
|
|
|
7
11
|
/*! *****************************************************************************
|
|
8
12
|
Copyright (c) Microsoft Corporation.
|
|
@@ -352,6 +356,19 @@
|
|
|
352
356
|
{ type: dialog.MatDialogRef }
|
|
353
357
|
]; };
|
|
354
358
|
|
|
359
|
+
var NxsSwiperTemplateDirective = /** @class */ (function () {
|
|
360
|
+
function NxsSwiperTemplateDirective() {
|
|
361
|
+
}
|
|
362
|
+
return NxsSwiperTemplateDirective;
|
|
363
|
+
}());
|
|
364
|
+
NxsSwiperTemplateDirective.decorators = [
|
|
365
|
+
{ type: core.Directive, args: [{
|
|
366
|
+
selector: '[nxsSwiperTemplate]',
|
|
367
|
+
},] }
|
|
368
|
+
];
|
|
369
|
+
|
|
370
|
+
// install Swiper modules
|
|
371
|
+
SwiperCore__default['default'].use([SwiperCore.Navigation, SwiperCore.Pagination, SwiperCore.Autoplay, SwiperCore.Lazy, SwiperCore.Thumbs]);
|
|
355
372
|
var NxsCarouselComponent = /** @class */ (function () {
|
|
356
373
|
function NxsCarouselComponent(matDialog, zone, platformId, config) {
|
|
357
374
|
this.matDialog = matDialog;
|
|
@@ -359,10 +376,9 @@
|
|
|
359
376
|
this.platformId = platformId;
|
|
360
377
|
this.config = config;
|
|
361
378
|
this.lazy = true;
|
|
362
|
-
this.mutationObserver = null;
|
|
363
|
-
this.recreateSliderSubscribed = false;
|
|
364
379
|
this.eventsCollector = new events.EventsCollector();
|
|
365
|
-
this.options =
|
|
380
|
+
this.options = null;
|
|
381
|
+
this.thumbnailsOptions = null;
|
|
366
382
|
this.hasHtmlContent = false;
|
|
367
383
|
this.slidesCount = 0;
|
|
368
384
|
this.slideChange = new core.EventEmitter();
|
|
@@ -378,15 +394,7 @@
|
|
|
378
394
|
Object.defineProperty(NxsCarouselComponent.prototype, "setOptions", {
|
|
379
395
|
set: function (val) {
|
|
380
396
|
this.options = this.setDefaultOptions(val, false);
|
|
381
|
-
|
|
382
|
-
enumerable: false,
|
|
383
|
-
configurable: true
|
|
384
|
-
});
|
|
385
|
-
Object.defineProperty(NxsCarouselComponent.prototype, "setImages", {
|
|
386
|
-
set: function (val) {
|
|
387
|
-
this.images = val;
|
|
388
|
-
this.initSlides();
|
|
389
|
-
this.createSlider(true);
|
|
397
|
+
this.setThumbnailsOptions();
|
|
390
398
|
},
|
|
391
399
|
enumerable: false,
|
|
392
400
|
configurable: true
|
|
@@ -400,156 +408,20 @@
|
|
|
400
408
|
return;
|
|
401
409
|
console.log.apply(console, __spreadArray(['[NxsCarousel]'], __read(args)));
|
|
402
410
|
};
|
|
403
|
-
NxsCarouselComponent.prototype.onContentChange = function (changes) {
|
|
404
|
-
// console.log("Log: NxsCarouselComponent -> onContentChange -> changes", changes);
|
|
405
|
-
// changes.forEach(change => console.log(change.target));
|
|
406
|
-
};
|
|
407
|
-
NxsCarouselComponent.prototype.initSlides = function () {
|
|
408
|
-
var _this = this;
|
|
409
|
-
if (!this.isBrowser) {
|
|
410
|
-
this.log('prevent initSlides on platform server');
|
|
411
|
-
return;
|
|
412
|
-
}
|
|
413
|
-
if (!this.nxsSlidesWrapper) {
|
|
414
|
-
this.log('can not initSlides : nxsSlidesWrapper is not defined !');
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
this.log('initSlides begins');
|
|
418
|
-
this.zone.runOutsideAngular(function () {
|
|
419
|
-
var e_1, _d, e_2, _e;
|
|
420
|
-
if (!_this.hasHtmlContent && _this.images) {
|
|
421
|
-
_this.nxsSlidesWrapper.nativeElement.innerHTML = '';
|
|
422
|
-
try {
|
|
423
|
-
for (var _f = __values(_this.images), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
424
|
-
var cImage = _g.value;
|
|
425
|
-
var div = document.createElement('div');
|
|
426
|
-
div.className = 'swiper-slide';
|
|
427
|
-
if (_this.lazy) {
|
|
428
|
-
div.dataset.background = cImage.src;
|
|
429
|
-
div.className += ' swiper-lazy';
|
|
430
|
-
}
|
|
431
|
-
else {
|
|
432
|
-
div.style.backgroundImage = 'url(' + cImage.src + ')';
|
|
433
|
-
}
|
|
434
|
-
if (_this.options.nxsCarouselImageBackgroundSize)
|
|
435
|
-
div.style.backgroundSize = _this.options.nxsCarouselImageBackgroundSize;
|
|
436
|
-
_this.nxsSlidesWrapper.nativeElement.appendChild(div);
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
440
|
-
finally {
|
|
441
|
-
try {
|
|
442
|
-
if (_g && !_g.done && (_d = _f.return)) _d.call(_f);
|
|
443
|
-
}
|
|
444
|
-
finally { if (e_1) throw e_1.error; }
|
|
445
|
-
}
|
|
446
|
-
_this.slidesCount = _this.images.length;
|
|
447
|
-
if (!!_this.options.nxsThumbnails && _this.options.nxsThumbnails.show) {
|
|
448
|
-
_this.nxsThumbnailsSlidesWrapper.nativeElement.innerHTML = '';
|
|
449
|
-
try {
|
|
450
|
-
for (var _h = __values(_this.images), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
451
|
-
var cImage = _j.value;
|
|
452
|
-
var div = document.createElement('div');
|
|
453
|
-
div.className = 'swiper-slide';
|
|
454
|
-
if (_this.lazy) {
|
|
455
|
-
div.dataset.background = cImage.src;
|
|
456
|
-
div.className += ' swiper-lazy';
|
|
457
|
-
}
|
|
458
|
-
else {
|
|
459
|
-
div.style.backgroundImage = 'url(' + cImage.src + ')';
|
|
460
|
-
}
|
|
461
|
-
_this.nxsThumbnailsSlidesWrapper.nativeElement.appendChild(div);
|
|
462
|
-
}
|
|
463
|
-
}
|
|
464
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
465
|
-
finally {
|
|
466
|
-
try {
|
|
467
|
-
if (_j && !_j.done && (_e = _h.return)) _e.call(_h);
|
|
468
|
-
}
|
|
469
|
-
finally { if (e_2) throw e_2.error; }
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
_this.log('initSlides - images are defined - slides count => ', _this.slidesCount);
|
|
473
|
-
}
|
|
474
|
-
else if (_this.hasHtmlContent) {
|
|
475
|
-
_this.log('initSlides - html content - slides length => ', _this.nxsSlidesWrapper.nativeElement.children.length);
|
|
476
|
-
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
|
477
|
-
for (var i = 0; i < _this.nxsSlidesWrapper.nativeElement.children.length; i++) {
|
|
478
|
-
var child = _this.nxsSlidesWrapper.nativeElement.children[i];
|
|
479
|
-
if (!child.className)
|
|
480
|
-
child.className = 'swiper-slide';
|
|
481
|
-
else if (child.className.indexOf('swiper-slide') === -1) {
|
|
482
|
-
child.className += ' swiper-slide';
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
_this.slidesCount = _this.nxsSlidesWrapper.nativeElement.children.length;
|
|
486
|
-
_this.log('initSlides - html content - slides count => ', _this.slidesCount);
|
|
487
|
-
}
|
|
488
|
-
});
|
|
489
|
-
};
|
|
490
411
|
NxsCarouselComponent.prototype.destroy = function () {
|
|
491
|
-
var _a
|
|
412
|
+
var _a;
|
|
492
413
|
if (!this.isBrowser) {
|
|
493
414
|
return;
|
|
494
415
|
}
|
|
495
416
|
(_a = this.eventsCollector) === null || _a === void 0 ? void 0 : _a.unsubscribeAll();
|
|
496
|
-
(_b = this.mutationObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
497
|
-
(_c = this.sliderInstance) === null || _c === void 0 ? void 0 : _c.destroy();
|
|
498
417
|
};
|
|
499
418
|
NxsCarouselComponent.prototype.ngOnDestroy = function () {
|
|
500
419
|
this.destroy();
|
|
501
420
|
};
|
|
502
|
-
NxsCarouselComponent.prototype.subscribeToSlideChanged = function () {
|
|
503
|
-
var _this = this;
|
|
504
|
-
if (!this.hasHtmlContent) {
|
|
505
|
-
this.log('subscribeToSlideChanged cannot be subscribed : has no html content');
|
|
506
|
-
return;
|
|
507
|
-
}
|
|
508
|
-
if (!this.nxsSlidesWrapper || !this.nxsSlidesWrapper.nativeElement) {
|
|
509
|
-
this.log('subscribeToSlideChanged error : nxsSlidesWrapper is not defined');
|
|
510
|
-
return;
|
|
511
|
-
}
|
|
512
|
-
if (typeof MutationObserver === 'undefined') {
|
|
513
|
-
this.log('cannot use mutation observer');
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
if (this.mutationObserver)
|
|
517
|
-
this.mutationObserver.disconnect();
|
|
518
|
-
this.log('subscribe to mutation observer');
|
|
519
|
-
this.mutationObserver = new MutationObserver(function (mutationsList) {
|
|
520
|
-
var e_3, _d;
|
|
521
|
-
// console.log("Log: NxsCarouselComponent -> subscribeToSlideChanged -> mutationsList", mutationsList);
|
|
522
|
-
// console.log("Log: NxsCarouselComponent -> subscribeToSlideChanged -> MutationObserver");
|
|
523
|
-
_this.log('mutation observer - html content has changed');
|
|
524
|
-
if (mutationsList.length === 0)
|
|
525
|
-
return;
|
|
526
|
-
var mustUpdate = false;
|
|
527
|
-
try {
|
|
528
|
-
for (var mutationsList_1 = __values(mutationsList), mutationsList_1_1 = mutationsList_1.next(); !mutationsList_1_1.done; mutationsList_1_1 = mutationsList_1.next()) {
|
|
529
|
-
var mutation = mutationsList_1_1.value;
|
|
530
|
-
if (mutation.addedNodes.length > 0 || mutation.removedNodes.length > 0) {
|
|
531
|
-
mustUpdate = true;
|
|
532
|
-
break;
|
|
533
|
-
}
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
537
|
-
finally {
|
|
538
|
-
try {
|
|
539
|
-
if (mutationsList_1_1 && !mutationsList_1_1.done && (_d = mutationsList_1.return)) _d.call(mutationsList_1);
|
|
540
|
-
}
|
|
541
|
-
finally { if (e_3) throw e_3.error; }
|
|
542
|
-
}
|
|
543
|
-
if (mustUpdate) {
|
|
544
|
-
_this.initSlides();
|
|
545
|
-
_this.createSlider(true);
|
|
546
|
-
}
|
|
547
|
-
});
|
|
548
|
-
this.mutationObserver.observe(this.nxsSlidesWrapper.nativeElement, { childList: true, attributes: false, });
|
|
549
|
-
};
|
|
550
421
|
NxsCarouselComponent.prototype.ngAfterViewInit = function () {
|
|
551
|
-
this.
|
|
552
|
-
this.
|
|
422
|
+
// console.log('thi.contents', this.contents);
|
|
423
|
+
// this.initSlides();
|
|
424
|
+
// this.createSlider(true);
|
|
553
425
|
};
|
|
554
426
|
NxsCarouselComponent.prototype.getMainSliderHeight = function () {
|
|
555
427
|
if (!this.options)
|
|
@@ -567,10 +439,18 @@
|
|
|
567
439
|
NxsCarouselComponent.prototype.setDefaultOptions = function (options, forDialog) {
|
|
568
440
|
var _a;
|
|
569
441
|
if (!options && forDialog) {
|
|
570
|
-
options = {
|
|
442
|
+
options = {
|
|
443
|
+
nxsShowNavigationBullets: true, loop: true, nxsThumbnails: { show: true }, effect: 'slide', nxsShowNavigationArrows: true, nxsShowImagesCount: true,
|
|
444
|
+
lazy: true,
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
else if (!options) {
|
|
448
|
+
options = {
|
|
449
|
+
nxsShowNavigationBullets: true, loop: true,
|
|
450
|
+
nxsThumbnails: { show: false }, effect: 'slide', nxsShowNavigationArrows: true, nxsShowImagesCount: false, nxsCarouselDialogOptions: {},
|
|
451
|
+
lazy: true,
|
|
452
|
+
};
|
|
571
453
|
}
|
|
572
|
-
else if (!options)
|
|
573
|
-
options = { nxsShowNavigationBullets: true, loop: true, nxsThumbnails: { show: false }, effect: 'slide', nxsShowNavigationArrows: true, nxsShowImagesCount: false, nxsCarouselDialogOptions: {} };
|
|
574
454
|
if (options.nxsCarouselDialogOptions) {
|
|
575
455
|
if (typeof options.nxsCarouselDialogOptions.nxsThumbnails === 'undefined')
|
|
576
456
|
options.nxsCarouselDialogOptions.nxsThumbnails = { show: false };
|
|
@@ -606,8 +486,37 @@
|
|
|
606
486
|
options.nxsfullscreenOnClick = false;
|
|
607
487
|
if (options.nxsThumbnails.onMainSlider)
|
|
608
488
|
options.nxsShowNavigationBullets = false;
|
|
489
|
+
if (typeof options.lazy === 'undefined')
|
|
490
|
+
options.lazy = true;
|
|
491
|
+
if (typeof options.navigation === 'undefined')
|
|
492
|
+
options.navigation = true;
|
|
493
|
+
if (typeof options.pagination === 'undefined')
|
|
494
|
+
options.pagination = { clickable: true };
|
|
495
|
+
// console.log("Log ~ file: nxs-carousel.component.ts ~ line 272 ~ NxsCarouselComponent ~ setDefaultOptions ~ options", options);
|
|
609
496
|
return options;
|
|
610
497
|
};
|
|
498
|
+
NxsCarouselComponent.prototype.setThumbnailsOptions = function () {
|
|
499
|
+
var _a, _b;
|
|
500
|
+
if (!!((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.nxsThumbnails) === null || _b === void 0 ? void 0 : _b.show)) {
|
|
501
|
+
this.thumbnailsOptions = {
|
|
502
|
+
slidesPerView: this.options.nxsThumbnails.perView,
|
|
503
|
+
loop: false,
|
|
504
|
+
freeMode: true,
|
|
505
|
+
// watchSlidesVisibility: true,
|
|
506
|
+
watchSlidesProgress: true,
|
|
507
|
+
breakpoints: this.options.nxsThumbnails.breakpoints,
|
|
508
|
+
// spaceBetween: 10,
|
|
509
|
+
};
|
|
510
|
+
if (this.lazy) {
|
|
511
|
+
// Disable preloading of all images
|
|
512
|
+
this.thumbnailsOptions.preloadImages = false;
|
|
513
|
+
// Enable lazy loading
|
|
514
|
+
this.thumbnailsOptions.lazy = true;
|
|
515
|
+
}
|
|
516
|
+
// this.thumbnailsSliderInstance = new Swiper(this.nxsThumbnailsSliderContainer.nativeElement, thumbnailsOptions);
|
|
517
|
+
// this.options.thumbs = { swiper: this.thumbnailsSliderInstance };
|
|
518
|
+
}
|
|
519
|
+
};
|
|
611
520
|
NxsCarouselComponent.prototype.showFullScreenCarousel = function (images, wrapperClass) {
|
|
612
521
|
this.options.nxsCarouselDialogOptions = this.setDefaultOptions(this.options.nxsCarouselDialogOptions, true);
|
|
613
522
|
var data = { images: images, wrapperClass: wrapperClass, options: this.options.nxsCarouselDialogOptions };
|
|
@@ -619,125 +528,79 @@
|
|
|
619
528
|
disableClose: !this.options.nxsCarouselDialogExitable,
|
|
620
529
|
});
|
|
621
530
|
};
|
|
622
|
-
NxsCarouselComponent.prototype.createSlider = function (forceRecreate) {
|
|
623
|
-
var _this = this;
|
|
624
|
-
if (!this.isBrowser) {
|
|
625
|
-
this.log('prevent createSlider : platform is server');
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
if (!this.nxsSliderContainer) {
|
|
629
|
-
this.log('can not createSlider : nxsSliderContainer is not defined !');
|
|
630
|
-
return;
|
|
631
|
-
}
|
|
632
|
-
this.log('createSlider', this.nxsSliderContainer.nativeElement);
|
|
633
|
-
if (this.slidesCount === 0) {
|
|
634
|
-
this.log('can not createSlider : slidesCount === 0');
|
|
635
|
-
this.subscribeToSlideChanged();
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
if (this.sliderInstance && !forceRecreate) {
|
|
639
|
-
this.log('can re create slider => slider is already created.');
|
|
640
|
-
return;
|
|
641
|
-
}
|
|
642
|
-
this.zone.runOutsideAngular(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
643
|
-
var _d, Swiper, thumbnailsOptions;
|
|
644
|
-
var _this = this;
|
|
645
|
-
return __generator(this, function (_e) {
|
|
646
|
-
switch (_e.label) {
|
|
647
|
-
case 0:
|
|
648
|
-
this.destroy();
|
|
649
|
-
this.options.pagination = {
|
|
650
|
-
el: '.nxs-carousel-pagination',
|
|
651
|
-
clickable: true,
|
|
652
|
-
type: 'bullets',
|
|
653
|
-
};
|
|
654
|
-
this.options.navigation = {
|
|
655
|
-
nextEl: '.nxs-carousel-button-next',
|
|
656
|
-
prevEl: '.nxs-carousel-button-prev',
|
|
657
|
-
};
|
|
658
|
-
if (!!this.swiperLibrary) return [3 /*break*/, 2];
|
|
659
|
-
_d = this;
|
|
660
|
-
return [4 /*yield*/, import('swiper')];
|
|
661
|
-
case 1:
|
|
662
|
-
_d.swiperLibrary = _e.sent();
|
|
663
|
-
_e.label = 2;
|
|
664
|
-
case 2:
|
|
665
|
-
Swiper = this.swiperLibrary.default;
|
|
666
|
-
if (!!this.options.nxsThumbnails && this.options.nxsThumbnails.show) {
|
|
667
|
-
thumbnailsOptions = {
|
|
668
|
-
slidesPerView: this.options.nxsThumbnails.perView,
|
|
669
|
-
loop: false,
|
|
670
|
-
freeMode: true,
|
|
671
|
-
watchSlidesVisibility: true,
|
|
672
|
-
watchSlidesProgress: true,
|
|
673
|
-
breakpoints: this.options.nxsThumbnails.breakpoints,
|
|
674
|
-
// spaceBetween: 10,
|
|
675
|
-
};
|
|
676
|
-
if (this.lazy) {
|
|
677
|
-
// Disable preloading of all images
|
|
678
|
-
thumbnailsOptions.preloadImages = false;
|
|
679
|
-
// Enable lazy loading
|
|
680
|
-
thumbnailsOptions.lazy = true;
|
|
681
|
-
}
|
|
682
|
-
this.thumbnailsSliderInstance = new Swiper(this.nxsThumbnailsSliderContainer.nativeElement, thumbnailsOptions);
|
|
683
|
-
this.options.thumbs = { swiper: this.thumbnailsSliderInstance };
|
|
684
|
-
}
|
|
685
|
-
if (this.lazy) {
|
|
686
|
-
// Disable preloading of all images
|
|
687
|
-
this.options.preloadImages = false;
|
|
688
|
-
// Enable lazy loading
|
|
689
|
-
this.options.lazy = true;
|
|
690
|
-
}
|
|
691
|
-
// console.log("Log ~ file: nxs-carousel.component.ts ~ line 323 ~ NxsCarouselComponent ~ this.zone.runOutsideAngular ~ this.options", this.options);
|
|
692
|
-
this.sliderInstance = new Swiper(this.nxsSliderContainer.nativeElement, this.options);
|
|
693
|
-
this.log('sliderInstance has been created', this.sliderInstance);
|
|
694
|
-
this.sliderInstance.on('slideChange', function () {
|
|
695
|
-
_this.zone.run(function () {
|
|
696
|
-
_this.currentSlide = _this.sliderInstance.realIndex;
|
|
697
|
-
_this.log("slideChange", _this.currentSlide);
|
|
698
|
-
_this.slideChange.next(_this.currentSlide);
|
|
699
|
-
});
|
|
700
|
-
});
|
|
701
|
-
this.sliderInstance.on('click', function (evt) {
|
|
702
|
-
var target = evt.target;
|
|
703
|
-
if (target.className.indexOf('nxs-carousel-button') !== -1 || target.className.indexOf('swiper-pagination') !== -1)
|
|
704
|
-
return;
|
|
705
|
-
_this.zone.run(function () {
|
|
706
|
-
_this.slideClick.next(evt);
|
|
707
|
-
if (_this.options.nxsfullscreenOnClick && _this.images && _this.images.length && !_this.hasHtmlContent) {
|
|
708
|
-
_this.showFullScreenCarousel(_this.images, 'fullscreen-carousel');
|
|
709
|
-
}
|
|
710
|
-
});
|
|
711
|
-
});
|
|
712
|
-
this.subscribeToSlideChanged();
|
|
713
|
-
return [2 /*return*/];
|
|
714
|
-
}
|
|
715
|
-
});
|
|
716
|
-
}); });
|
|
717
|
-
};
|
|
718
531
|
NxsCarouselComponent.prototype.goToSlide = function (index, speed) {
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
this.sliderInstance.slideTo(index, speed);
|
|
532
|
+
var _a;
|
|
533
|
+
(_a = this.swiperInstance) === null || _a === void 0 ? void 0 : _a.slideTo(index, speed);
|
|
722
534
|
};
|
|
723
535
|
NxsCarouselComponent.prototype.next = function () {
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
this.sliderInstance.slideNext();
|
|
536
|
+
var _a;
|
|
537
|
+
(_a = this.swiperInstance) === null || _a === void 0 ? void 0 : _a.slideNext();
|
|
727
538
|
};
|
|
728
539
|
NxsCarouselComponent.prototype.previous = function () {
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
540
|
+
var _a;
|
|
541
|
+
(_a = this.swiperInstance) === null || _a === void 0 ? void 0 : _a.slidePrev();
|
|
542
|
+
};
|
|
543
|
+
NxsCarouselComponent.prototype.onSwiperThumbnails = function (instance) {
|
|
544
|
+
var _a, _b;
|
|
545
|
+
if ((_b = (_a = this.options) === null || _a === void 0 ? void 0 : _a.nxsThumbnails) === null || _b === void 0 ? void 0 : _b.show)
|
|
546
|
+
this.thumbnailsSwiperInstance = instance;
|
|
547
|
+
else
|
|
548
|
+
this.thumbnailsSwiperInstance = null;
|
|
549
|
+
// if (this.options?.nxsThumbnails?.show) {
|
|
550
|
+
// const optionsClone = MainHelpers.cloneObject(this.options);
|
|
551
|
+
// optionsClone.thumbs = { swiper: this.thumbnailsSwiperInstance };
|
|
552
|
+
// // this.options = optionsClone;
|
|
553
|
+
// // this.options = { ...this.options, thumbs: { swiper: this.thumbnailsSwiperInstance } };
|
|
554
|
+
// console.log("Log ~ file: nxs-carousel.component.ts ~ line 416 ~ NxsCarouselComponent ~ onSwiperThumbnails ~ this.options ", this.options);
|
|
555
|
+
// this.options.thumbs = { swiper: this.thumbnailsSwiperInstance };
|
|
556
|
+
// }
|
|
557
|
+
};
|
|
558
|
+
NxsCarouselComponent.prototype.onSwiper = function (instance) {
|
|
559
|
+
var _this = this;
|
|
560
|
+
this.log('swiper ready - instance', instance);
|
|
561
|
+
this.swiperInstance = instance;
|
|
562
|
+
this.swiperInstance.on('click', function (swiperInstance, evt) {
|
|
563
|
+
// console.log("Log ~ file: nxs-carousel.component.ts ~ line 392 ~ NxsCarouselComponent ~ this.swiperInstance.on ~ evt", evt);
|
|
564
|
+
var target = evt.target;
|
|
565
|
+
if (target.className.indexOf('nxs-carousel-button') !== -1 || target.className.indexOf('swiper-pagination') !== -1)
|
|
566
|
+
return;
|
|
567
|
+
_this.runInZone(function () {
|
|
568
|
+
_this.slideClick.next(evt);
|
|
569
|
+
if (_this.options.nxsfullscreenOnClick && _this.images && _this.images.length && !_this.hasHtmlContent) {
|
|
570
|
+
_this.showFullScreenCarousel(_this.images, 'fullscreen-carousel');
|
|
571
|
+
}
|
|
572
|
+
});
|
|
573
|
+
});
|
|
574
|
+
};
|
|
575
|
+
NxsCarouselComponent.prototype.runInZone = function (callback) {
|
|
576
|
+
var args = [];
|
|
577
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
578
|
+
args[_i - 1] = arguments[_i];
|
|
579
|
+
}
|
|
580
|
+
if (!this.zone) {
|
|
581
|
+
callback(args);
|
|
582
|
+
}
|
|
583
|
+
return this.zone.run(function () { return callback(args); });
|
|
584
|
+
};
|
|
585
|
+
NxsCarouselComponent.prototype.onSlideChange = function (instances) {
|
|
586
|
+
var _this = this;
|
|
587
|
+
// this.swiperInstance = instance;
|
|
588
|
+
// this.log('slide change - instance', instance);
|
|
589
|
+
this.runInZone(function () {
|
|
590
|
+
var _a;
|
|
591
|
+
_this.currentSlide = ((_a = _this.swiperInstance) === null || _a === void 0 ? void 0 : _a.realIndex) || 0;
|
|
592
|
+
_this.log('slide change - currentSlide', _this.currentSlide);
|
|
593
|
+
_this.slideChange.next(_this.currentSlide);
|
|
594
|
+
});
|
|
732
595
|
};
|
|
733
596
|
return NxsCarouselComponent;
|
|
734
597
|
}());
|
|
735
598
|
NxsCarouselComponent.decorators = [
|
|
736
599
|
{ type: core.Component, args: [{
|
|
737
600
|
selector: 'nxs-carousel',
|
|
738
|
-
template: "<div
|
|
601
|
+
template: "<div *ngIf=\"options\"\n [ngClass]=\"{'swiper-container':true,'nxs-slider-with-thumbnails':!!options.nxsThumbnails && options.nxsThumbnails.show}\"\n [style.height]=\"getMainSliderHeight()\">\n <swiper [config]=\"options\" (swiper)=\"onSwiper($event)\" (slideChange)=\"onSlideChange($event)\"\n [thumbs]=\"{ swiper: thumbnailsSwiperInstance }\">\n <ng-container *ngIf=\"hasHtmlContent\">\n <ng-template *ngFor=\"let slide of contents\" swiperSlide>\n <ng-template [ngTemplateOutlet]=\"slide\" [ngTemplateOutletContext]=\"{\n $implicit: slide\n }\"></ng-template>\n </ng-template>\n </ng-container>\n <ng-container *ngIf=\"!hasHtmlContent && images?.length\">\n <ng-template swiperSlide *ngFor=\"let slideImage of images\">\n <img class=\"nxs-image-slide swiper-lazy\" [attr.data-src]=\"slideImage.src\" />\n <div class=\"swiper-lazy-preloader swiper-lazy-preloader-black\"></div>\n </ng-template>\n </ng-container>\n </swiper>\n <ng-container *ngIf=\"images && options.nxsShowImagesCount\">\n <div class=\"nxs-image-counter\">\n {{currentSlide+1}} / {{images.length}}\n </div>\n </ng-container>\n</div>\n\n<div *ngIf=\"thumbnailsOptions && images?.length\"\n [style.height]=\"(!!options.nxsThumbnails && options.nxsThumbnails.show && !!options.nxsThumbnails.percentHeight) ? (options.nxsThumbnails.percentHeight + '%'):''\"\n [style.top]=\"(!!options.nxsThumbnails && options.nxsThumbnails.show && !!options.nxsThumbnails.percentHeight && options.nxsThumbnails.onMainSlider) ? ('-' + (options.nxsThumbnails.percentHeight) + '%'):''\"\n [ngClass]=\"{'swiper-container':true, 'nxs-slider-thumbnails-container':true,'nxs-slider-thumbnails-on-main-slider':options.nxsThumbnails && options.nxsThumbnails.onMainSlider}\">\n <swiper [config]=\"thumbnailsOptions\" (swiper)=\"onSwiperThumbnails($event)\">\n <ng-template swiperSlide *ngFor=\"let slideImage of images\">\n <img class=\"nxs-image-slide swiper-lazy\" [attr.data-src]=\"slideImage.src\" />\n <div class=\"swiper-lazy-preloader swiper-lazy-preloader-black\"></div>\n </ng-template>\n </swiper>\n</div>",
|
|
739
602
|
encapsulation: core.ViewEncapsulation.None,
|
|
740
|
-
styles: ["nxs-carousel{display:block;height:100%;position:relative;--swiper-navigation-color:#fff;--swiper-theme-color:#fff}nxs-carousel .swiper-container{width:100%;display:block;position:relative
|
|
603
|
+
styles: ["@import \"~swiper/swiper.min.css\";@import \"~swiper/modules/navigation/navigation.min.css\";@import \"~swiper/modules/pagination/pagination.min.css\";@import \"~swiper/modules/lazy/lazy.min.css\";nxs-carousel{display:block;height:100%;position:relative;--swiper-navigation-color:#fff;--swiper-pagination-color:#fff;--swiper-theme-color:#fff}nxs-carousel .swiper-container{width:100%;height:100%;display:block;position:relative}nxs-carousel .swiper-container swiper{height:100%}nxs-carousel .swiper-container .swiper-wrapper .swiper-slide{height:100%;position:relative;width:100%;min-height:50px;background-size:cover;background-position:50%;background-repeat:no-repeat}nxs-carousel .swiper-container .nxs-image-slide{height:100%;-o-object-fit:cover;object-fit:cover;width:100%;-o-object-position:center;object-position:center}nxs-carousel .swiper-container.nxs-slider-with-thumbnails{height:80%}nxs-carousel .swiper-container.nxs-slider-thumbnails-container{height:20%;background:transparent;padding:6px 0}nxs-carousel .swiper-container.nxs-slider-thumbnails-container .swiper-slide{cursor:pointer;border-radius:6px;margin:0 6px;border:2px solid transparent}nxs-carousel .swiper-container.nxs-slider-thumbnails-container .swiper-slide.swiper-slide-thumb-active{border:2px solid #add8e6}nxs-carousel .swiper-container.nxs-slider-thumbnails-on-main-slider{top:-20%}nxs-carousel .nxs-image-counter{position:absolute;top:0;right:0;color:#fff;padding:4px;font-weight:700;z-index:10}"]
|
|
741
604
|
},] }
|
|
742
605
|
];
|
|
743
606
|
NxsCarouselComponent.ctorParameters = function () { return [
|
|
@@ -747,13 +610,11 @@
|
|
|
747
610
|
{ type: NxsCarouselModuleConfig, decorators: [{ type: core.Optional }] }
|
|
748
611
|
]; };
|
|
749
612
|
NxsCarouselComponent.propDecorators = {
|
|
613
|
+
contents: [{ type: core.ContentChildren, args: [NxsSwiperTemplateDirective, { read: core.TemplateRef },] }],
|
|
614
|
+
swiperComponent: [{ type: core.ViewChild, args: ['swiper', { static: false },] }],
|
|
750
615
|
lazy: [{ type: core.Input }],
|
|
751
|
-
|
|
752
|
-
nxsSlidesWrapper: [{ type: core.ViewChild, args: ['nxsSlidesWrapper', { static: true },] }],
|
|
753
|
-
nxsThumbnailsSliderContainer: [{ type: core.ViewChild, args: ['nxsThumbnailsSliderContainer', { static: true },] }],
|
|
754
|
-
nxsThumbnailsSlidesWrapper: [{ type: core.ViewChild, args: ['nxsThumbnailsSlidesWrapper', { static: true },] }],
|
|
616
|
+
images: [{ type: core.Input }],
|
|
755
617
|
setOptions: [{ type: core.Input, args: ['options',] }],
|
|
756
|
-
setImages: [{ type: core.Input, args: ['images',] }],
|
|
757
618
|
hasHtmlContent: [{ type: core.Input }],
|
|
758
619
|
slideChange: [{ type: core.Output }],
|
|
759
620
|
slideClick: [{ type: core.Output }]
|
|
@@ -777,16 +638,18 @@
|
|
|
777
638
|
declarations: [
|
|
778
639
|
NxsCarouselComponent,
|
|
779
640
|
NxsCarouselDialogComponent,
|
|
641
|
+
NxsSwiperTemplateDirective,
|
|
780
642
|
],
|
|
781
643
|
imports: [
|
|
782
644
|
common.CommonModule,
|
|
783
645
|
icon.MatIconModule,
|
|
784
646
|
button.MatButtonModule,
|
|
785
647
|
dialog.MatDialogModule,
|
|
786
|
-
|
|
648
|
+
angular.SwiperModule,
|
|
787
649
|
],
|
|
788
650
|
exports: [
|
|
789
651
|
NxsCarouselComponent,
|
|
652
|
+
NxsSwiperTemplateDirective,
|
|
790
653
|
],
|
|
791
654
|
},] }
|
|
792
655
|
];
|
|
@@ -798,7 +661,8 @@
|
|
|
798
661
|
exports.NxsCarouselComponent = NxsCarouselComponent;
|
|
799
662
|
exports.NxsCarouselModule = NxsCarouselModule;
|
|
800
663
|
exports.NxsCarouselModuleConfig = NxsCarouselModuleConfig;
|
|
801
|
-
exports.ɵa =
|
|
664
|
+
exports.ɵa = NxsSwiperTemplateDirective;
|
|
665
|
+
exports.ɵb = NxsCarouselDialogComponent;
|
|
802
666
|
|
|
803
667
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
804
668
|
|