var zoomstart;
var imgBackup;
+var zoomTouchID;
let imgEvHandler = {
handleEvent: function(aEvent) {
let canvas = document.getElementById("mbrotImage");
let context = canvas.getContext("2d");
+ let touchEvent = aEvent.type.indexOf('touch') != -1;
+
+ // Bail out if this is neither a touch nor left-click.
+ if (!touchEvent && aEvent.button != 0)
+ return;
+
+ // Bail out if the started touch can't be found.
+ if (touchEvent && zoomstart &&
+ !aEvent.changedTouches.identifiedTouch(zoomTouchID))
+ return;
+
+ let coordObj = touchEvent ?
+ aEvent.changedTouches.identifiedTouch(zoomTouchID) :
+ aEvent;
+
switch (aEvent.type) {
case 'mousedown':
case 'touchstart':
- if (aEvent.button == 0) {
- // left button - start dragzoom
- zoomstart = {x: aEvent.clientX - canvas.offsetLeft,
- y: aEvent.clientY - canvas.offsetTop};
- imgBackup = context.getImageData(0, 0, canvas.width, canvas.height);
+ if (touchEvent) {
+ zoomTouchID = aEvent.changedTouches.item(0).identifier;
+ coordObj = aEvent.changedTouches.identifiedTouch(zoomTouchID);
}
+ // left button - start dragzoom
+ zoomstart = {x: coordObj.clientX - canvas.offsetLeft,
+ y: coordObj.clientY - canvas.offsetTop};
+ imgBackup = context.getImageData(0, 0, canvas.width, canvas.height);
break;
case 'mouseup':
case 'touchend':
- if (aEvent.button == 0 && zoomstart) {
+ if (zoomstart) {
context.putImageData(imgBackup, 0, 0);
- let zoomend = {x: aEvent.clientX - canvas.offsetLeft,
- y: aEvent.clientY - canvas.offsetTop};
+ let zoomend = {x: coordObj.clientX - canvas.offsetLeft,
+ y: coordObj.clientY - canvas.offsetTop};
// make sure zoomend is bigger than zoomstart
if ((zoomend.x == zoomstart.x) || (zoomend.y == zoomstart.y)) {
break;
case 'mousemove':
case 'touchmove':
- if (aEvent.button == 0 && zoomstart) {
+ if (zoomstart) {
context.putImageData(imgBackup, 0, 0);
context.strokeStyle = "rgb(255,255,31)";
context.strokeRect(zoomstart.x, zoomstart.y,
- aEvent.clientX - canvas.offsetLeft - zoomstart.x,
- aEvent.clientY - canvas.offsetTop - zoomstart.y);
+ coordObj.clientX - canvas.offsetLeft - zoomstart.x,
+ coordObj.clientY - canvas.offsetTop - zoomstart.y);
}
break;
}
na.setAttribute("disabled", "true");
}
-function goBack () {
+function goBack() {
if (gLastImageData) {
Services.prefs.setIntPref("mandelbrot.iteration_max",
gLastImageData.iterMax);
<Description>
<em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
<em:minVersion>4.0</em:minVersion>
- <em:maxVersion>11.0a1</em:maxVersion>
+ <em:maxVersion>12.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- SeaMonkey -->
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1</em:minVersion>
- <em:maxVersion>2.8a1</em:maxVersion>
+ <em:maxVersion>2.9a1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- Fennec -->
<Description>
<em:id>{a23983c0-fd0e-11dc-95ff-0800200c9a66}</em:id>
<em:minVersion>4.0</em:minVersion>
- <em:maxVersion>11.0a1</em:maxVersion>
+ <em:maxVersion>12.0a1</em:maxVersion>
</Description>
</em:targetApplication>
<!-- toolkit -->
<Description>
<em:id>toolkit@mozilla.org</em:id>
<em:minVersion>2.0</em:minVersion>
- <em:maxVersion>11.0</em:maxVersion>
+ <em:maxVersion>12.0</em:maxVersion>
</Description>
</em:targetApplication>
</Description>