Skip to content

Commit bcc3908

Browse files
gaborcsjamesdaily
authored andcommitted
docs(guide/directive): fix myDraggable for zoomed page
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
1 parent 1b8cd7f commit bcc3908

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

docs/content/guide/directive.ngdoc

+4-4
Original file line numberDiff line numberDiff line change
@@ -748,15 +748,15 @@ element?
748748
element.on('mousedown', function(event) {
749749
// Prevent default dragging of selected content
750750
event.preventDefault();
751-
startX = event.screenX - x;
752-
startY = event.screenY - y;
751+
startX = event.pageX - x;
752+
startY = event.pageY - y;
753753
$document.on('mousemove', mousemove);
754754
$document.on('mouseup', mouseup);
755755
});
756756

757757
function mousemove(event) {
758-
y = event.screenY - startY;
759-
x = event.screenX - startX;
758+
y = event.pageY - startY;
759+
x = event.pageX - startX;
760760
element.css({
761761
top: y + 'px',
762762
left: x + 'px'

0 commit comments

Comments
 (0)