0

I have placed an image on canvas, now I want to be able to drag and drop it anywhere on the canvas. How do I go about it?.

var imageObj = new Image();
     imageObj.src = "bulb.jpg";

 imageObj.onload = function() {
      canvasContext.drawImage(imageObj, 200,80);        
      };
Cyprian
  • 19
  • 2
  • Did you consider using a plugin ? https://jqueryui.com/draggable/ is pretty useful. – Demeter Dimitri Aug 22 '16 at 14:05
  • The plugin worked great, I have another question is there a way I can use an if statement such that if the image is moved from its original position then something happens. – Cyprian Aug 23 '16 at 08:23
  • @ Demeter Dimitri the plugin worked great though I have another question, is there a way I can use an if statement such that if image is dragged from its original position then something happens. – Cyprian Aug 23 '16 at 08:28
  • This post can help you. http://stackoverflow.com/questions/4127118/can-you-detect-dragging-in-jquery – Demeter Dimitri Aug 23 '16 at 12:02

0 Answers0