Skip to content

Commit

Permalink
fix(angular): custom html element support
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky committed Apr 8, 2021
1 parent 5b18d8e commit dec54c2
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/angular/src/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' ||
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<SwiperSlideDirective>;
private slides: SwiperSlideDirective[];
Expand Down Expand Up @@ -453,7 +467,6 @@ export class SwiperComponent implements OnInit {
const { params } = getParams(this);
Object.assign(this, params);
}

ngAfterViewInit() {
this.childrenSlidesInit();
this.initSwiper();
Expand Down

0 comments on commit dec54c2

Please sign in to comment.