Skip to content

Commit

Permalink
fix(draggable): fix offset during drag
Browse files Browse the repository at this point in the history
when the scrollX/Y is changed during drag (e.g. by the mousewheel)
the offset wasn't correct
  • Loading branch information
hrosenbauer authored and vieron committed Jun 16, 2014
1 parent 93c46ff commit c726c4a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/jquery.draggable.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@
var diff_y = Math.round(mouse_actual_pos.top - this.mouse_init_pos.top);

var left = Math.round(this.el_init_offset.left +
diff_x - this.baseX + this.scroll_offset_x);
diff_x - this.baseX + window.scrollX - this.win_offset_x);
var top = Math.round(this.el_init_offset.top +
diff_y - this.baseY + this.scroll_offset_y);
diff_y - this.baseY + window.scrollY - this.win_offset_y);

if (this.options.limit) {
if (left > this.player_max_left) {
Expand All @@ -151,8 +151,8 @@
pointer: {
left: mouse_actual_pos.left,
top: mouse_actual_pos.top,
diff_left: diff_x + this.scroll_offset_x,
diff_top: diff_y + this.scroll_offset_y
diff_left: diff_x + (window.scrollX - this.win_offset_x),
diff_top: diff_y + (window.scrollY - this.win_offset_y)
}
};
};
Expand Down Expand Up @@ -299,6 +299,8 @@
this.helper = false;
}

this.win_offset_y = window.scrollY;
this.win_offset_x = window.scrollX;
this.scroll_offset_y = 0;
this.scroll_offset_x = 0;
this.el_init_offset = this.$player.offset();
Expand Down

0 comments on commit c726c4a

Please sign in to comment.