diff --git a/src/angular/src/swiper.component.ts b/src/angular/src/swiper.component.ts index bc821162d..0eaace5e4 100644 --- a/src/angular/src/swiper.component.ts +++ b/src/angular/src/swiper.component.ts @@ -163,7 +163,9 @@ export class SwiperComponent implements OnInit { prevEl: currentPrev || null, }); if ( + val !== true && typeof this._navigation !== 'boolean' && + this._navigation?.prevEl !== this._prevElRef?.nativeElement && (typeof this._navigation?.nextEl === 'string' || typeof this._navigation?.prevEl === 'string' || typeof this._navigation?.nextEl === 'object' || @@ -185,7 +187,9 @@ export class SwiperComponent implements OnInit { el: current || null, }); if ( + val !== true && typeof this._pagination !== 'boolean' && + this._pagination?.el !== this._paginationElRef?.nativeElement && (typeof this._pagination?.el === 'string' || typeof this._pagination?.el === 'object') ) { this.showPagination = false; @@ -204,7 +208,9 @@ export class SwiperComponent implements OnInit { el: current || null, }); if ( + val !== true && typeof this._scrollbar !== 'boolean' && + this._scrollbar?.el !== this._scrollbarElRef?.nativeElement && (typeof this._scrollbar?.el === 'string' || typeof this._scrollbar?.el === 'object') ) { this.showScrollbar = false; @@ -392,20 +398,28 @@ export class SwiperComponent implements OnInit { @ViewChild('prevElRef', { static: false }) set prevElRef(el: ElementRef) { + this._prevElRef = el; this._setElement(el, this.navigation, 'navigation', 'prevEl'); } + _prevElRef: ElementRef; @ViewChild('nextElRef', { static: false }) set nextElRef(el: ElementRef) { + this._nextElRef = el; this._setElement(el, this.navigation, 'navigation', 'nextEl'); } + _nextElRef: ElementRef; @ViewChild('scrollbarElRef', { static: false }) set scrollbarElRef(el: ElementRef) { + this._scrollbarElRef = el; this._setElement(el, this.scrollbar, 'scrollbar'); } + _scrollbarElRef: ElementRef; @ViewChild('paginationElRef', { static: false }) set paginationElRef(el: ElementRef) { + this._paginationElRef = el; this._setElement(el, this.pagination, 'pagination'); } + _paginationElRef: ElementRef; @ContentChildren(SwiperSlideDirective, { descendants: true, emitDistinctChangesOnly: true }) slidesEl: QueryList; private slides: SwiperSlideDirective[]; @@ -453,7 +467,6 @@ export class SwiperComponent implements OnInit { const { params } = getParams(this); Object.assign(this, params); } - ngAfterViewInit() { this.childrenSlidesInit(); this.initSwiper();