I am trying to implement the functionality for "panning" inside a canvas in HTML5, and I'm not sure how best to do this.
Currently - I am trying to determine where the mouse is on the canvas, and if it is within 10% of the edge, it will move in this direction, as shown below:
Current Edge Detection:
canvas.onmousemove = function(e) { var x = e.offsetX; var y = e.offsetY; var cx = canvas.width; var cy = canvas.height; if(x <= 0.1*cx && y <= 0.1*cy) { alert("Upper Left");
I know that perhaps I could do this by creating paths in the canvas and associating events with them, but I did not work with them much, so I thought I would ask here. Also - if the "enveloping" panorama was possible, which would be amazing (panning to the left will be directed over time).
Summary: I wonder what the best route to achieve panning is within the HTML5 Canvas. It will not use images, but really drawn objects (if that matters). I will be happy to answer any questions if I can.
Demo:
Demo
source share