leonardosalles / ionic2-zoom-area

A zoom area component with pinch support
MIT License
33 stars 13 forks source link

$event undefined error #11

Closed darron1217 closed 6 years ago

darron1217 commented 6 years ago

I copied the codes from example and run it. But the $event returns undefined. Is it working well with latest ionic3?

home.html

<ion-header>
  <ion-navbar>
    <ion-title>
      Ionic Blank
    </ion-title>
  </ion-navbar>
</ion-header>

<ion-content>
  <zoom-area [(scale)]="scale" (afterZoomIn)="afterZoomIn($event)" (afterZoomOut)="afterZoomOut($event)" [(controls)]="showControls">
    <img src="https://www.gettyimages.ca/gi-resources/images/Homepage/Hero/UK/CMS_Creative_164657191_Kingfisher.jpg" alt="Zoom It">
  </zoom-area>
</ion-content>

home.ts

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  showControls: boolean = true;
  scale: number = 1;

  constructor(public navCtrl: NavController) {
  }

  afterZoomIn (event) {
    console.log('After ZoomIn Event: ', event);
  }

  afterZoomOut (event) {
    console.log('After ZoomOut Event: ', event);
  }
}

image

leonardosalles commented 6 years ago

This is just because Angular requires that $event to propagate it properly, in the component I am not passing nothing to the listener so 'undefined' is right. What you expect to receive in this event? So I can change it to send some useful information.

darron1217 commented 6 years ago

No, you don't have to do anything :) I just wondered is it error or not.