Browse Source

Merge branch 'master' of github.com:Jaxan/beats-website

master
Joshua Moerman 12 years ago
parent
commit
c2ed93a2a8
  1. 26
      drawing.js

26
drawing.js

@ -12,10 +12,17 @@ var drawing = {
}; };
function down(e){ function down(e){
line.starting_point.x = e.pageX - this.offsetLeft; var x = e.pageX, y = e.pageY;
line.starting_point.y = e.pageY - this.offsetTop; var obj = e.target;
line.end_point.x = e.pageX - this.offsetLeft; do {
line.end_point.y = e.pageY - this.offsetTop; x -= obj.offsetLeft;
y -= obj.offsetTop;
} while(obj = obj.offsetParent);
line.starting_point.x = x;
line.starting_point.y = y;
line.end_point.x = x;
line.end_point.y = y;
drawing.active = true; drawing.active = true;
drawing.draw_start(line); drawing.draw_start(line);
@ -29,8 +36,15 @@ function up(e){
function move(e){ function move(e){
if(drawing.active){ if(drawing.active){
line.end_point.x = e.pageX - this.offsetLeft; var x = e.pageX, y = e.pageY;
line.end_point.y = e.pageY - this.offsetTop; var obj = e.target;
do {
x -= obj.offsetLeft;
y -= obj.offsetTop;
} while(obj = obj.offsetParent);
line.end_point.x = x;
line.end_point.y = y;
drawing.draw_move(line); drawing.draw_move(line);
} }