I'm not the best person to be giving out code samples, but, I've got a draggable div, and this may help. Not sure if there's another way, and, I know nothing of jquery, but, this uses listeners for mouseup, mousedown, and mousemove. The div created elsewhere, and is styled with a class named "dragme", and I have previously stored a reference to the div in refTradePanel.

  -- Ed

var isdrag = false;
var x, y, tx, ty;

document.addEventListener('mouseup', function(e) {
    isdrag=false
    }, true);

document.addEventListener('mousedown', function(e) {
    var fobj = e.target;
    if (fobj.className=="dragme") {
        isdrag = true;
tx = parseInt(refTradePanel.style.left+0); // must have been working ty = parseInt(refTradePanel.style.top+0); // with different fudge numbers
        x = e.clientX;
        y = e.clientY;
        }
    }, true);

document.addEventListener('mousemove', function(e) {
    if(isdrag) {
        var setX = tx + e.clientX - x;
        var setY = ty + e.clientY - y;

        refTradePanel.style.left = setX + "px";
        refTradePanel.style.top  = setY + "px";
        }
    }, true);

--
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en.

Reply via email to