Friday, July 17th, 2009
HTML5 Drag and Drop in deeetail
Les Orchard isn't just a cool domain name. He is a person. A person who has done a great job detailing HTML 5 drag and drop that you can use today in Firefox 3.5.

Les takes us down the path from simple drag and drop, to event propagation, to feedback images, to rich data transfer information all with great demos:
- Old school drag and drop
- New school drag and drop
- New school drag and drop, now with Event Delegation!
- Using drag feedback images
- Using data transfer content types
- Using drag effects
It is so cool to be able to do things like this:
-
-
var dt = ev.originalEvent.dataTransfer;
-
-
dt.setDragImage( $('#feedback_image h2')[0], 0, 0);
-
-
dt.setDragImage( $('#logo')[0], 32, 32);
-
-
var canvas = document.createElement("canvas");
-
canvas.width = canvas.height = 50;
-
-
var ctx = canvas.getContext("2d");
-
ctx.lineWidth = 8;
-
ctx.moveTo(25,0);
-
ctx.lineTo(50, 50);
-
ctx.lineTo(0, 50);
-
ctx.lineTo(25, 0);
-
ctx.stroke();
-
-
dt.setDragImage(canvas, 25, 25);
-
Drag and drop on the Web has always been a strange beast, but at least now we have a rich API.... so maybe it will get a revival?












Some of the demos also work in Webkit nightlies. Really cool.
Finally something in HTML5 that is actually useful and has a chance of being implemented by Microsoft.
@Darkimmortal : System Drag&Drop has been introduced in 2000 in IE 5.0. My two cents…
See
We have also implementation of this Drag&Drop API (initially created by MS, as noted by SleepyDog) with minor limitations in Ample SDK http://www.amplesdk.com/examples/extensions/ Works in all browsers.
This also works in Safari Webkit nightlies. Not sure if it works in straight 4.0.2.
Webkit nightlies supports the
draggableattribute, but Safari 4.x doesn’t just yet. Oddly you need to kick it with CSS using-khtml-user-drag: element;I wrote an article for html5doctors.com last week or so ago going through DnD and cross browser issues to watch out for: native HTML 5 drag and drop.
I don’t get it. Why does WHAT-WG prefer to solve problems which already have solutions?
Drag’n'drop is very easy to implement if you use Flapjax for example.
Interesting to know that CSS may be formatted in so many styles. It was interesting to me.
Thanks for that
We are leraning
With the changing trend of the world, wedding apart from white,Princess Strapless Satin Evening Dress ivory, beige and other traditional colors,are also increasingly popular in recent years, ghetto prom dressespink wedding package,gothic prom dresses such as pink, pink orange, baby blue, purple night, light green and light silver-gray, very soft and pleasing to wedding hair accessoriesthe eye; if you have the courage to try, dark green, purplish red, deep purple, decorated in pink wedding dress, the formation of rich colors,the dress, the effect is very special;Sash Lace Satin Flower Girl Dress, laden with flour colored silk flowers, butterflies, in order to add color.wedding dressIn fact, the wedding is the color of lesser importance, the most important prerequisite is to match the bride’s complexion. Oriental deep and yellowish color, wearing white Mermaid Satin Organdie Wedding Dress,will appear dull, wearing ivory would be more harmonious and natural, baby blue, wedding accessoriespurple night can not be coordinated with the yellow, but pink orange, light green with yellowish color match. As for the skin and rosy, or bronze skin, wearing white will look great, wedding dress