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

Commit

Permalink
fix: images behave correctly after being viewed several times
Browse files Browse the repository at this point in the history
close #14 #16
  • Loading branch information
SimonGolms committed Feb 11, 2020
1 parent 201aa12 commit 445ad78
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
</ion-toolbar>
</ion-header>

<ion-content [forceOverscroll]="false" fullscreen="true">
<ion-content [forceOverscroll]="false">
<ion-slides [options]="options" #sliderRef>
<ion-slide>
<!-- <ion-slide>
<div class="swiper-zoom-container">
<img [alt]="this.alt" [src]="this.src" (error)="onError($event)" />
</div>
</ion-slide>
</ion-slide> -->
</ion-slides>
</ion-content>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,20 @@ export class ViewerModalComponent implements OnInit {

constructor(private modalController: ModalController) {}

ngOnInit() {
async ngOnInit() {
this.options = { ...this.defaultSlideOptions, ...this.slideOptions };
this.src = this.srcHighRes || this.src;
this.setStyle();
this.setScheme(this.scheme);
this.initSwipeToClose(this.swipeToClose);

/**
* Current Workaround
* See reported bug: https://github.com/ionic-team/ionic/issues/19638#issuecomment-584828315
* Hint: Comment in '<ion-slide>' in component
*/
const swiper = await this.slides.getSwiper();
swiper.appendSlide(`<ion-slide><img alt=${this.alt} src="${this.src}" (error)="(onError($event))"/></ion-slide>`);
}

setStyle() {
Expand Down Expand Up @@ -194,6 +202,7 @@ export class ViewerModalComponent implements OnInit {
}

onError(error) {
console.log('TCL: ViewerModalComponent -> onError -> error', error);
if (this.srcFallback) {
this.src = this.srcFallback;
}
Expand Down

0 comments on commit 445ad78

Please sign in to comment.