Skip to content
This repository has been archived by the owner on Aug 6, 2022. It is now read-only.

Commit

Permalink
Fixed merge conflicts from the 4.x.x merge
Browse files Browse the repository at this point in the history
  • Loading branch information
sconix committed Sep 28, 2017
2 parents e4a7f82 + 1d77b30 commit 771f3d3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Angular wrapper library for Swiper",
"bugs": "https://github.com/zefoy/ngx-swiper-wrapper/issues",
"license": "MIT",
"version": "5.0.0-2",
"version": "5.0.0-3",
"main": "bundles/ngx-swiper-wrapper.umd.js",
"module": "./dist/index.js",
"typings": "./dist/index.d.ts",
Expand Down
28 changes: 21 additions & 7 deletions src/lib/swiper.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,10 @@ export class SwiperComponent implements OnInit, OnDestroy {

ngOnInit() {
this.zone.runOutsideAngular(() => {
this.mo = new MutationObserver((mutations) => {
const children = this.swiperSlides.nativeElement.children;

for (let i = 0; i < children.length; i++) {
children[i].classList.add('swiper-slide');
}
this.updateClasses();

this.directiveRef.update();
this.mo = new MutationObserver((mutations) => {
this.updateClasses();
});

this.mo.observe(this.swiperSlides.nativeElement, { childList: true });
Expand Down Expand Up @@ -161,4 +157,22 @@ export class SwiperComponent implements OnInit, OnDestroy {

return options;
}

updateClasses() {
let updateNeeded = false;

const children = this.swiperSlides.nativeElement.children;

for (let i = 0; i < children.length; i++) {
if (!children[i].classList.contains('swiper-slide')) {
updateNeeded = true;

children[i].classList.add('swiper-slide');
}
}

if (updateNeeded) {
this.directiveRef.update();
}
}
}

0 comments on commit 771f3d3

Please sign in to comment.