Skip to content

Instantly share code, notes, and snippets.

@riix
Created July 24, 2012 06:39
Show Gist options
  • Save riix/3168412 to your computer and use it in GitHub Desktop.
Save riix/3168412 to your computer and use it in GitHub Desktop.
객체 이동, Move Element
var mover = false;
var currx = 0;
var curry = 0;
$(".calculator .title").mousedown(function(eventObject){
mover = true;
currx = eventObject.pageX;
curry = eventObject.pageY;
});
$(window).bind('mousemove', function(eventObject) {
if(!mover)
return;
var obj = $(".calculator");
mouseX = eventObject.pageX;
mouseY = eventObject.pageY;
x = obj.position().left;
y = obj.position().top;
obj.css({
left: x + (mouseX-currx),
top: y + (mouseY-curry),
});
currx = eventObject.pageX;
curry = eventObject.pageY;
});
$(".calculator .title").mouseup(function() {
mover = false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment