
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML5 Canvas and select / drag-and-drop features in a JS library?
If you want to use HTML5 canvas to draw shapes, texts and curves and also want to attach traditional DOM events like onClick or drag and drop functions, a crossbar framework Raphael is used for doing drag and drop or touch events.
This technology uses SVG and XML for older versions of IE. Drag and drag using HTML is shown below.
Example
<!DOCTYPE html> <html lang = "en"> <head> <meta charset = "utf-8"> <title>Raphaël · Drag-n-drop</title> <link rel = "stylesheet" href = "demo.css" type = "text/css" media = "screen"> <meta name = "apple-mobile-web-app-capable" content = "yes"> <link rel = "apple-touch-icon-precomposed" href = "/Raphael.png"> <link rel = "stylesheet" href = "demo-print.css" type = "text/css" media = "print"> <script src = "raphael.js"></script> <script> window.onload = function () { var R = Raphael(0, 0, "100%", "100%"), r = R.circle(100, 100, 50).attr({fill: "hsb(0, 1, 1)", stroke: "none", opacity: .5}), g = R.circle(210, 100, 50).attr({fill: "hsb(.3, 1, 1)", stroke: "none", opacity: .5}), b = R.circle(320, 100, 50).attr({fill: "hsb(.6, 1, 1)", stroke: "none", opacity: .5}), p = R.circle(430, 100, 50).attr({fill: "hsb(.8, 1, 1)", stroke: "none", opacity: .5}); var start = function () { this.ox = this.attr("cx"); this.oy = this.attr("cy"); this.animate({r: 70, opacity: .25}, 500, ">"); }, move = function (dx, dy) { this.attr({cx: this.ox + dx, cy: this.oy + dy}); }, up = function () { this.animate({r: 50, opacity: .5}, 500, ">"); }; R.set(r, g, b, p).drag(move, start, up); }; </script> </head> <body> <div id = "holder"></div> <p id = "copy">Demo of <a href = "http://raphaeljs.com/">Raphaël</a>— JavaScript Vector Library</p> </body> </html>
- Related Articles
- Drag and Drop a File feature in React JS
- HTML5 drag and drop will not drop
- How to use drag and drop in HTML5?
- How to simulate HTML5 Drag and Drop in Selenium Webdriver?
- The dragLeave event fires before drop for HTML5 drag and drop events
- Drop Shadow with HTML5 Canvas
- How to use drag and drop in Android?
- How to use GoJS HTML5 Canvas Library for drawing diagrams and graphs?
- How to do drag and drop action in Selenium?
- How to perform drag and drop actions in WebdriverIO?
- Cross-browser drag-and-drop HTML file upload?
- Full page drag and drop files website with HTML
- How to perform drag and drop operation in Selenium with python?
- How to stop dragend's default behavior in drag and drop?
- How to Add Drag and Drop in React using React Beautiful DnD

Advertisements