0

I am quite new in JavaScript. I found a code that zoom an image.My question is how will add pinch event on below JavaScript code so the image will scale base on pinch?

Here is the HTML code

 <html>
 <body>  
  <map id="map" name="map">
    <area coords="15,92,568,247" alt="Blah" href="javascript:alert('hello');" />
    <area coords="18,259,546,432" alt="Blah" href="javascript:alert('hello 2');" />
  </map>
  <input type="button" value="+" onclick="javascript:ZoomIn();"/>
  <input type="button" value="-" onclick="javascript:ZoomOut();"/><br />
  <img src="Highlight cells.png" usemap="#map" id="image" />

Javascript Code

function ZoomIn() {
  Zoom(1.1);
}

function ZoomOut() {
  Zoom(0.9);
}

function Zoom(amount) {
  // resize image
  var image = document.getElementById('image');
  image.height = image.height * amount;

  // resize image map
  var map = document.getElementById('map');
  for (var i = 0; i < map.areas.length; i++) {
    var area = map.areas[i];
    var coords = area.coords.split(',');
    for (var j = 0; j < coords.length; j++) {
      coords[j] = coords[j] * amount;
    }
    area.coords = coords[0] + ',' + coords[1] + ',' + coords[2] + ',' + coords[3];
  }
} 
JessieBear
  • 133
  • 1
  • 14
  • 2
    http://stackoverflow.com/questions/11183174/simplest-way-to-detect-a-pinch – ufucuk Sep 29 '16 at 06:29
  • Does this answer your question? [Simplest way to detect a pinch](https://stackoverflow.com/questions/11183174/simplest-way-to-detect-a-pinch) – TAbdiukov Feb 10 '21 at 01:52

0 Answers0