Skip to content

Commit

Permalink
fix(angular): custom naviation & pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
vltansky committed Apr 27, 2021
1 parent 2902ea9 commit c96bcf6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
31 changes: 12 additions & 19 deletions src/angular/src/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
setProperty,
ignoreNgOnChanges,
coerceBooleanProperty,
isShowEl,
} from './utils/utils';
import {
SwiperOptions,
Expand Down Expand Up @@ -169,13 +170,15 @@ export class SwiperComponent implements OnInit {
prevEl: currentPrev || null,
});
if (
coerceBooleanProperty(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' ||
typeof this._navigation?.prevEl === 'object')
coerceBooleanProperty(val) !== true ||
(this._navigation &&
typeof this._navigation !== 'boolean' &&
this._navigation.prevEl !== this._prevElRef?.nativeElement &&
(this._navigation.prevEl !== null || this._navigation.nextEl !== null) &&
(typeof this._navigation.nextEl === 'string' ||
typeof this._navigation.prevEl === 'string' ||
typeof this._navigation.nextEl === 'object' ||
typeof this._navigation.prevEl === 'object'))
) {
this.showNavigation = false;
}
Expand All @@ -192,12 +195,7 @@ export class SwiperComponent implements OnInit {
this._pagination = setProperty(val, {
el: current || null,
});
if (
coerceBooleanProperty(val) !== true &&
typeof this._pagination !== 'boolean' &&
this._pagination?.el !== this._paginationElRef?.nativeElement &&
(typeof this._pagination?.el === 'string' || typeof this._pagination?.el === 'object')
) {
if (isShowEl(val, this._pagination, this._paginationElRef)) {
this.showPagination = false;
}
}
Expand All @@ -213,12 +211,7 @@ export class SwiperComponent implements OnInit {
this._scrollbar = setProperty(val, {
el: current || null,
});
if (
coerceBooleanProperty(val) !== true &&
typeof this._scrollbar !== 'boolean' &&
this._scrollbar?.el !== this._scrollbarElRef?.nativeElement &&
(typeof this._scrollbar?.el === 'string' || typeof this._scrollbar?.el === 'object')
) {
if (isShowEl(val, this._scrollbar, this._scrollbarElRef)) {
this.showScrollbar = false;
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/angular/src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ export function isObject(o) {
);
}

export function isShowEl(val, obj, el) {
return (
coerceBooleanProperty(val) !== true ||
(obj &&
typeof obj !== 'boolean' &&
obj.el !== el?.nativeElement &&
(typeof obj.el !== 'string' || typeof obj.el !== 'object'))
);
}

export function extend(target, src) {
const noExtend = ['__proto__', 'constructor', 'prototype'];
Object.keys(src)
Expand Down

0 comments on commit c96bcf6

Please sign in to comment.