{"comment":{"created_at":"2011-10-26T16:13:23Z","body":"You should use `d3.event.dx` and `d3.event.dy` instead of the global `event` object.  You will need to sum the deltas manually, of course. :)  Normally what I do is set `this.__origin__` to some value on dragstart and use that, and then delete it on dragend.","updated_at":"2011-10-26T16:13:23Z","url":"https://api.github.com/repos/mbostock/d3/issues/comments/2532392","id":2532392,"user":{"avatar_url":"https://secure.gravatar.com/avatar/f9dd9f4c2b8d081b67fe34769e24808e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"f9dd9f4c2b8d081b67fe34769e24808e","url":"https://api.github.com/users/jasondavies","id":31223,"login":"jasondavies"}},"action":"created","issue":{"number":266,"created_at":"2011-08-24T11:50:07Z","pull_request":{"diff_url":null,"patch_url":null,"html_url":null},"body":"Many of my drag event handlers are now something like:\r\n\r\n```javascript\r\nfunction(d) {\r\n  d.x = Math.max(0, Math.min(w, d.x + d3.event.dx));\r\n}\r\n```\r\n\r\nHowever, if the mouse is dragged outside of [0, w] and then back in again, d.x will be offset by the distance the mouse was moved outside.\r\n\r\nIs this a good enough use case to warrant reporting the offset since dragstart as well as the offset since the last drag event?  There are ways around it of course, but they involve adding dragstart and dragend handlers, which would be nice to avoid for brevity.\r\n\r\nEdit: actually I probably want the current absolute drag position rather than dragstart offset if I want to avoid a dragstart handler.","comments":3,"title":"Report dragstart offset in d3.behavior.drag?","updated_at":"2011-10-26T16:13:23Z","url":"https://api.github.com/repos/mbostock/d3/issues/266","id":1473750,"assignee":null,"milestone":null,"closed_at":null,"user":{"avatar_url":"https://secure.gravatar.com/avatar/f9dd9f4c2b8d081b67fe34769e24808e?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png","gravatar_id":"f9dd9f4c2b8d081b67fe34769e24808e","url":"https://api.github.com/users/jasondavies","id":31223,"login":"jasondavies"},"html_url":"https://github.com/mbostock/d3/issues/266","labels":[],"state":"open"},"legacy":{"issue_id":1473750,"comment_id":2532392}}