Guest User

Untitled

a guest
Jun 25th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <ion-header>
  2.  
  3. <ion-navbar>
  4. <ion-title>imageEdit</ion-title>
  5. </ion-navbar>
  6.  
  7. </ion-header>
  8.  
  9. <ion-content>
  10. <img #img src="https://www.w3schools.com/w3css/img_lights.
  11. <div>
  12. <button ion-button>Text</button>
  13. </div>
  14. </ion-content>
  15.  
  16. import { Component, ViewChild, ElementRef } from '@angular/core';
  17. import { NavController, Gesture } from 'ionic-angular';
  18.  
  19. @Component({
  20. selector: 'page-image-edit',
  21. templateUrl: 'image-edit.html',
  22. })
  23. export class ImageEditPage {
  24.  
  25. @ViewChild('img') imgElem: ElementRef;
  26. img: HTMLImageElement;
  27. gesture: Gesture;
  28.  
  29. constructor() {}
  30.  
  31. ionViewDidLoad() {
  32. this.img = this.imgElem.nativeElement;
  33.  
  34. if(!this.img){
  35. alert('Cannot get img element!');
  36. return;
  37. }
  38. this.img.style.width = '100%';
  39. this.img.style.height = 'auto';
  40.  
  41. this.attachGestures();
  42. }
  43.  
  44. attachGestures(){
  45. this.gesture = new Gesture(this.imgElem.nativeElement);
  46. this.gesture.listen();
  47. this.gesture.on('rotate', (e) =>{
  48. console.log('rotation');
  49. });
  50. this.gesture.on('pinch', (e) =>{
  51. console.log('pinching');
  52. });
  53. }
  54. }
Add Comment
Please, Sign In to add comment