Created
November 1, 2011 04:29
-
-
Save tolmasky/1329937 to your computer and use it in GitHub Desktop.
On HTML5 Drag and Drop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("dragstart", function(event) | |
{ | |
event.dataTransfer.setData("image/png", slides.imageRep()); | |
event.dataTransfer.setData("slides", slides.serializedRep()); | |
// etc. | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event.dataTransfer.setData("slides", function() | |
{ | |
return costlySerialization(); | |
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
event.dataTransfer.setData("slides", { toString: function() | |
{ | |
return costlySerialization(); | |
} } ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)mouseDown:(NSEvent *)anEvent | |
{ | |
[NSView dragImage:myImage /*...*/]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)mouseDragged:(NSEvent *)anEvent | |
{ | |
if (deltaX > 10) | |
[NSView dragIamge:myImage /*...*/]; | |
else | |
[self modifySelection]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.addEventListener("mousedown", function(event) | |
{ | |
event.startDrag(); | |
}, false); | |
document.addEventListener("mousemove", function(event) | |
{ | |
if (someCondition) | |
event.startDrag(); | |
}, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dragEvent.dataTransfer.setDragImage(aDOMElement, offsetX, offsetY); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment