mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-04-05 15:41:03 +00:00
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 #4687
This commit is contained in:
parent
d3b38dda06
commit
3d4c80cc3e
1 changed files with 4 additions and 4 deletions
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in a new issue