Guest User

Untitled

a guest
Jul 20th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. var draggable;
  2.  
  3. // disable IE specialities
  4. document.ondragstart = function () { return false; };
  5.  
  6. // bound dragging into document
  7. var doc = $(document).bind("mousedown mouseup", function(e) {
  8.  
  9. var el = $(e.target);
  10.  
  11. if (e.type == "mousedown" && el.data("drag")) {
  12. var y = el.offset().top - e.pageY;
  13.  
  14. doc.bind("mousemove", function(evt) {
  15. if (!draggable) {
  16. draggable = el.css({position: 'absolute'});
  17. el.trigger("dragstart");
  18. }
  19. el.css({ top: evt.pageY + y }).trigger("drag");
  20. });
  21.  
  22. e.preventDefault();
  23.  
  24. // mouseup
  25. } else if (draggable) {
  26. draggable.css({ position: 'static'}).trigger("dragend");
  27. doc.unbind("mousemove");
  28. draggable = 0;
  29. }
  30.  
  31. });
  32.  
  33. $.fn.mootdrag = function() {
  34. return this.data("drag", true);
  35. };
Add Comment
Please, Sign In to add comment