I can't think of a good way to do this, so carefully study any other answers that are given to you. In particular, I doubt that binding events directly to the canvas is a good idea, and using the setTimeout call to handle panning and clicking is simply bad.
Here it works in action: http://jsfiddle.net/ryleyb/RFeEt/
All I did was connect the drag and dragend on the canvas that the fleet creates and set a global variable so that you know that the pan is happening. After panning is complete, it waits for 100 ms before disabling the panning variable, which will stop the action of your click.
var panning = false; $('#placeholder canvas').bind('drag',function(){ panning = true; }); $('#placeholder canvas').bind('dragend',function(){ setTimeout(function() {panning = false; }, 100); }); placeholder.bind('plotclick', function (event, pos, item) { if (!panning){ $('.message').append('plotclick triggered<br>'); } });
source share