Thursday, 11 October 2012

HTML5 Canvas - Drop-n-Drop Free Objects

This script shows how to create a drag-n-drop effect in a HTML5 Canvas. The following features are adopted and can be used in other projects.

  • A drag-n-drop rectangle object is defined.
  • A drag-n-drop circle object is defined.
  • A framework for handling drag-n-drop objects is defined.
  • A boundary can be defined in a drag-n-drop object to bound the object in a specified region.

This text is displayed if your browser does not support HTML5 Canvas.

Two boundaries are defined in the script, the objects cannot move beyond the left and top edges of the canvas. Try to drag and push the objects in the canvas to the top left corner of the canvas to see the effect of a boundary.

Source Code


No comments:

Post a Comment