Skip to content

Instantly share code, notes, and snippets.

@kenoir
Created July 11, 2012 09:39
Show Gist options
  • Save kenoir/3089313 to your computer and use it in GitHub Desktop.
Save kenoir/3089313 to your computer and use it in GitHub Desktop.
For simulating drag drop events (not in IE).
var Droop = function(){
}
Droop.simulateDragStart = function(target){
var e = new Event('mousedown');
target.dispatchEvent(e);
}
Droop.simulateDrag = function(position){
var e = new Event('mousemove');
e.pageY = position.y;
e.pageX = position.x;
document.dispatchEvent(e);
}
Droop.simulateDrop = function(target){
var e = new Event('mouseup');
e.target = target;
document.dispatchEvent(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment