Skip to content

Commit

Permalink
docs(guide/directive): fix myDraggable for zoomed page
Browse files Browse the repository at this point in the history
If you have zoomed into the page in your browser then the screen coordinate system no longer
matches the page coordinate system.  To ensure that dragged elements work correctly when zoomed
we should use pageX/pageY rather than screenX/screenY.

Closes angular#4687
  • Loading branch information
gaborcs authored and jamesdaily committed Jan 27, 2014
1 parent 83efebc commit aabb8dc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/content/guide/directive.ngdoc
Original file line number Diff line number Diff line change
Expand Up @@ -748,15 +748,15 @@ element?
element.on('mousedown', function(event) {
// Prevent default dragging of selected content
event.preventDefault();
startX = event.screenX - x;
startY = event.screenY - y;
startX = event.pageX - x;
startY = event.pageY - y;
$document.on('mousemove', mousemove);
$document.on('mouseup', mouseup);
});

function mousemove(event) {
y = event.screenY - startY;
x = event.screenX - startX;
y = event.pageY - startY;
x = event.pageX - startX;
element.css({
top: y + 'px',
left: x + 'px'
Expand Down

0 comments on commit aabb8dc

Please sign in to comment.