Skip to content

Commit

Permalink
Adapted it for Ionic RC5
Browse files Browse the repository at this point in the history
  • Loading branch information
nikini committed Jan 15, 2017
1 parent 6f507c9 commit 0c4e31d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ionic-gallery-modal",
"version": "0.0.7",
"version": "0.0.8",
"description": "Ionic 2 Gallery Modal (to preview photos)",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion src/gallery-modal/gallery-modal.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
</div>

<!-- Slider with images -->
<ion-slides #slider [options]="slideOptions" class="slider" *ngIf="photos.length" [ngStyle]="{ 'visibility': sliderLoaded ? 'visible' : 'hidden' }">
<ion-slides #slider [initialSlide]="initialSlide" class="slider" *ngIf="photos.length" [ngStyle]="{ 'visibility': sliderLoaded ? 'visible' : 'hidden' }">
<ion-slide *ngFor="let photo of photos;">
<zoomable-image
src="{{ photo.url }}"
[ngClass]="{ 'swiper-no-swiping': sliderDisabled }"
(disableScroll)="disableScroll($event)"
(enableScroll)="enableScroll($event)"
[parentSubject]="parentSubject"
Expand Down
11 changes: 2 additions & 9 deletions src/gallery-modal/gallery-modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,16 @@ export class GalleryModal {

public photos: Photo[];
private sliderDisabled: boolean = false;
private swiper: any;
private initialSlide: number = 0;
private currentSlide: number = 0;
private sliderLoaded: boolean = false;
private slideOptions: any = {};
private closeIcon: string = 'arrow-back';
private parentSubject: Subject<any> = new Subject();

constructor(private viewCtrl: ViewController, params: NavParams, private element: ElementRef, private platform: Platform) {
this.photos = params.get('photos') || [];
this.closeIcon = params.get('closeIcon') || 'arrow-back';
this.initialSlide = params.get('initialSlide') || 0;
this.slideOptions.initialSlide = this.initialSlide;
}

/**
Expand Down Expand Up @@ -70,9 +67,7 @@ export class GalleryModal {
*/
private disableScroll(event) {
if (!this.sliderDisabled) {
this.swiper = this.slider.getSlider();
this.currentSlide = this.swiper.activeIndex;
this.swiper.destroy(false);
this.currentSlide = this.slider.getActiveIndex();
this.sliderDisabled = true;
}
}
Expand All @@ -84,9 +79,7 @@ export class GalleryModal {
*/
private enableScroll(event) {
if (this.sliderDisabled) {
this.swiper = this.slider.getSlider();
this.swiper.init();
this.swiper.slideTo(this.currentSlide, 0, false);
this.slider.slideTo(this.currentSlide, 0, false);
this.sliderDisabled = false;
}
}
Expand Down

0 comments on commit 0c4e31d

Please sign in to comment.