Skip to content

Commit 6f507c9

Browse files
committed
Fixed a lot of stuff
1 parent 7ebeef6 commit 6f507c9

8 files changed

+44
-21
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ The possible options for it are:
7575
## Problems or suggestions
7676
Let us know or submit a PR! And, please, don't hesitate to contribute. :heart:
7777

78+
## Changelog
79+
80+
#### v0.0.7
81+
* Changed to work with Ionic 2 RC-5
82+
* Made a temporary fix for orientationchange bug in ios
83+
* Fixed a problem that was causing apps to not build
7884

7985
## Credits
8086
Ciprian Mocanu - [@nikini](http://github.com/nikini)

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ionic-gallery-modal",
3-
"version": "0.0.6",
3+
"version": "0.0.7",
44
"description": "Ionic 2 Gallery Modal (to preview photos)",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -24,6 +24,7 @@
2424
"license": "MIT",
2525
"devDependencies": {
2626
"@angular/compiler": "^2.2.1",
27+
"@types/core-js": "^0.9.35",
2728
"@types/node": "^6.0.57",
2829
"copyfiles": "^1.0.0",
2930
"gulp": "^3.9.1",
@@ -53,7 +54,7 @@
5354
"dist"
5455
],
5556
"repository": {
56-
"type" : "git",
57-
"url" : "https://github.com/nikini/ionic-gallery-modal.git"
57+
"type": "git",
58+
"url": "https://github.com/nikini/ionic-gallery-modal.git"
5859
}
5960
}

src/gallery-modal/gallery-modal.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ion-content #content class="gallery-modal">
1+
<ion-content #content class="gallery-modal" (window:resize)="resize($event)" (window:orientationchange)="orientationChange($event)">
22
<button class="close-button" ion-button icon-only (click)="dismiss()">
33
<ion-icon name="{{ closeIcon }}"></ion-icon>
44
</button>

src/gallery-modal/gallery-modal.ts

+19-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { Component, ViewChild, ViewEncapsulation } from '@angular/core';
2-
import { ViewController, NavParams, Slides, Content } from 'ionic-angular';
1+
import { Component, ViewChild, ViewEncapsulation, ElementRef } from '@angular/core';
2+
import { ViewController, NavParams, Slides, Content, Platform } from 'ionic-angular';
33
import { Photo } from '../interfaces/photo-interface';
44
import { Subject } from 'rxjs/Subject';
55

@@ -22,7 +22,7 @@ export class GalleryModal {
2222
private closeIcon: string = 'arrow-back';
2323
private parentSubject: Subject<any> = new Subject();
2424

25-
constructor(private viewCtrl: ViewController, params: NavParams) {
25+
constructor(private viewCtrl: ViewController, params: NavParams, private element: ElementRef, private platform: Platform) {
2626
this.photos = params.get('photos') || [];
2727
this.closeIcon = params.get('closeIcon') || 'arrow-back';
2828
this.initialSlide = params.get('initialSlide') || 0;
@@ -37,7 +37,22 @@ export class GalleryModal {
3737
}
3838

3939
private resize(event) {
40-
this.parentSubject.next(event);
40+
this.slider.update();
41+
42+
let width = this.element['nativeElement'].offsetWidth;
43+
let height = this.element['nativeElement'].offsetHeight;
44+
45+
this.parentSubject.next({
46+
width: width,
47+
height: height,
48+
});
49+
}
50+
51+
private orientationChange(event) {
52+
// TODO: See if you can remove timeout
53+
window.setTimeout(() => {
54+
this.resize(event);
55+
}, 150);
4156
}
4257

4358
/**

src/zoomable-image/zoomable-image.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<ion-scroll #ionScrollContainer scrollX="true" scrollY="true" zoom="false" (window:resize)="resize($event)">
1+
<ion-scroll #ionScrollContainer scrollX="true" scrollY="true" zoom="false">
22
<div #container class="image">
33
<img #image src="{{ src }}" alt="" />
44
</div>

src/zoomable-image/zoomable-image.ts

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, OnInit, OnDestroy, Input, Output, ViewChild, EventEmitter, ViewEncapsulation, ElementRef } from '@angular/core';
1+
import { Component, OnInit, OnDestroy, Input, Output, ViewChild, EventEmitter, ViewEncapsulation } from '@angular/core';
22
import { ViewController, Gesture, Scroll } from 'ionic-angular';
33
import { Subject } from 'rxjs/Subject';
44

@@ -56,7 +56,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
5656

5757
private imageElement: any;
5858

59-
constructor(private elementRef: ElementRef) {
59+
constructor() {
6060
}
6161

6262
public ngOnInit() {
@@ -100,13 +100,8 @@ export class ZoomableImage implements OnInit, OnDestroy {
100100
* Called every time the window gets resized
101101
*/
102102
public resize(event) {
103-
let node = this.elementRef.nativeElement;
104-
105-
if (node.parentElement) {
106-
node = node.parentElement;
107-
}
108103
// Set the wrapper dimensions first
109-
this.setWrapperDimensions(node.offsetWidth, node.offsetHeight);
104+
this.setWrapperDimensions(event.width, event.height);
110105

111106
// Get the image dimensions
112107
this.setImageDimensions();
@@ -118,7 +113,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
118113
* @param {number} width
119114
* @param {number} height
120115
*/
121-
private setWrapperDimensions(width:number = 0, height:number = 0) {
116+
private setWrapperDimensions(width:number, height:number) {
122117
this.dimensions.width = width || window.innerWidth;
123118
this.dimensions.height = height || window.innerHeight;
124119
}
@@ -290,7 +285,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
290285
*
291286
* @param {number} scale
292287
*/
293-
private animateScale(scale:number = 1) {
288+
private animateScale(scale:number) {
294289
this.scale += (scale - this.scale) / 5;
295290

296291
if (Math.abs(this.scale - scale) <= 0.1) {

tsconfig.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,18 @@
22
"compilerOptions": {
33
"emitDecoratorMetadata": true,
44
"experimentalDecorators": true,
5-
"target": "es6",
5+
"target": "es5",
66
"module": "commonjs",
77
"moduleResolution": "node",
88
"removeComments": true,
99
"sourceMap": true,
1010
"outDir": "dist-final",
11-
"types" : ["node"],
11+
"typeRoots": [
12+
"node_modules/@types"
13+
],
14+
"types": [
15+
"core-js"
16+
],
1217
"declaration": true
1318
},
1419
"include": [

typings.json

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"globalDependencies": {
3+
"es6-shim": "registry:dt/es6-shim#0.31.2+20160726072212"
34
}
45
}

0 commit comments

Comments
 (0)