Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var draggable;
- // disable IE specialities
- document.ondragstart = function () { return false; };
- // bound dragging into document
- var doc = $(document).bind("mousedown mouseup", function(e) {
- var el = $(e.target);
- if (e.type == "mousedown" && el.data("drag")) {
- var y = el.offset().top - e.pageY;
- doc.bind("mousemove", function(evt) {
- if (!draggable) {
- draggable = el.css({position: 'absolute'});
- el.trigger("dragstart");
- }
- el.css({ top: evt.pageY + y }).trigger("drag");
- });
- e.preventDefault();
- // mouseup
- } else if (draggable) {
- draggable.css({ position: 'static'}).trigger("dragend");
- doc.unbind("mousemove");
- draggable = 0;
- }
- });
- $.fn.mootdrag = function() {
- return this.data("drag", true);
- };
Add Comment
Please, Sign In to add comment