Instead of reset positioning
![]() ![]() |
Why not just prevent the dialog from leaving the screen? This is what I use for movement:
var initial_mouseX
var initial_mouseY
var initial_boxX
var initial_boxY
var el
function startMove (event) {//TODO wrap this up in an object
el = this.parentNode
initial_mouseX = event.clientX
initial_mouseY = event.clientY
if (el.style.right)
initial_boxX = 0
else
initial_boxX = document.body.clientWidth - el.offsetWidth - parseInt(el.style.left)
if (el.style.bottom)
initial_boxY = document.body.clientHeight - el.offsetHeight
else
initial_boxY = parseInt(el.style.top)
document.addEventListener('mousemove', move, true)
document.addEventListener('mouseup', endMove, true)
}
function move (event) {
var right = initial_boxX + initial_mouseX - event.clientX
var left = document.body.clientWidth - el.offsetWidth - right
el.style.right = ''
if (right < 15) {
el.style.right = 0
el.style.left = ''
} else if (left < 15)
el.style.left = 0
else
el.style.left = left + 'px'
var top = initial_boxY - initial_mouseY + event.clientY
var bottom = document.body.clientHeight - el.offsetHeight - top
el.style.bottom = ''
if (bottom < 15) {
el.style.bottom = 0
el.style.top = ''
} else if (top < 15)
el.style.top = 0
else
el.style.top = top + 'px'
}
function endMove () {
document.removeEventListener('mousemove', move, true)
document.removeEventListener('mouseup', endMove, true)
GM_setValue(el.id + '_left', el.style.left)
GM_setValue(el.id + '_top', el.style.top)
}
When the dialog is within 15 pixels of an edge, it will 'jump' to that edge w/o going past it. I haven't tested it on us.o so you might have to change It just bugs me that your script registers three menu commands. Edit: bugfix |
![]() ![]() |
hey thanks, I'll take a look at that :) |


