Skip to content

Instantly share code, notes, and snippets.

@tolmasky
Created November 1, 2011 04:29
Show Gist options
  • Save tolmasky/1329937 to your computer and use it in GitHub Desktop.
Save tolmasky/1329937 to your computer and use it in GitHub Desktop.
On HTML5 Drag and Drop
document.addEventListener("dragstart", function(event)
{
event.dataTransfer.setData("image/png", slides.imageRep());
event.dataTransfer.setData("slides", slides.serializedRep());
// etc.
}, false);
event.dataTransfer.setData("slides", function()
{
return costlySerialization();
} );
event.dataTransfer.setData("slides", { toString: function()
{
return costlySerialization();
} } );
- (void)mouseDown:(NSEvent *)anEvent
{
[NSView dragImage:myImage /*...*/];
}
- (void)mouseDragged:(NSEvent *)anEvent
{
if (deltaX > 10)
[NSView dragIamge:myImage /*...*/];
else
[self modifySelection];
}
document.addEventListener("mousedown", function(event)
{
event.startDrag();
}, false);
document.addEventListener("mousemove", function(event)
{
if (someCondition)
event.startDrag();
}, false);
dragEvent.dataTransfer.setDragImage(aDOMElement, offsetX, offsetY);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment