Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

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 #4687
  • Loading branch information
gaborcs authored and petebacondarwin committed Oct 28, 2013
1 parent d3b38dd commit 3d4c80c
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 3d4c80c

Please sign in to comment.