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' ;
2
2
import { ViewController , Gesture , Scroll } from 'ionic-angular' ;
3
3
import { Subject } from 'rxjs/Subject' ;
4
4
@@ -56,7 +56,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
56
56
57
57
private imageElement : any ;
58
58
59
- constructor ( private elementRef : ElementRef ) {
59
+ constructor ( ) {
60
60
}
61
61
62
62
public ngOnInit ( ) {
@@ -100,13 +100,8 @@ export class ZoomableImage implements OnInit, OnDestroy {
100
100
* Called every time the window gets resized
101
101
*/
102
102
public resize ( event ) {
103
- let node = this . elementRef . nativeElement ;
104
-
105
- if ( node . parentElement ) {
106
- node = node . parentElement ;
107
- }
108
103
// Set the wrapper dimensions first
109
- this . setWrapperDimensions ( node . offsetWidth , node . offsetHeight ) ;
104
+ this . setWrapperDimensions ( event . width , event . height ) ;
110
105
111
106
// Get the image dimensions
112
107
this . setImageDimensions ( ) ;
@@ -118,7 +113,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
118
113
* @param {number } width
119
114
* @param {number } height
120
115
*/
121
- private setWrapperDimensions ( width :number = 0 , height :number = 0 ) {
116
+ private setWrapperDimensions ( width :number , height :number ) {
122
117
this . dimensions . width = width || window . innerWidth ;
123
118
this . dimensions . height = height || window . innerHeight ;
124
119
}
@@ -290,7 +285,7 @@ export class ZoomableImage implements OnInit, OnDestroy {
290
285
*
291
286
* @param {number } scale
292
287
*/
293
- private animateScale ( scale :number = 1 ) {
288
+ private animateScale ( scale :number ) {
294
289
this . scale += ( scale - this . scale ) / 5 ;
295
290
296
291
if ( Math . abs ( this . scale - scale ) <= 0.1 ) {
0 commit comments