DmitryBaranovskiy / raphael

JavaScript Vector Library
https://dmitrybaranovskiy.github.io/raphael/
MIT License
11.27k stars 1.67k forks source link

Fix drag offsets passed to "drag.start" from touch drags in elproto.drag #1101

Closed kswenson closed 5 years ago

kswenson commented 6 years ago

Fixes a bug in which incorrect offsets were passed with touch drags. In elproto.drag, x and y are initialized to e.clientX and e.clientY respectively, but then there is code to update those values for touch events. Ultimately, the updated x and y values are added to scrollX/scrollY and then stored in this._drag.x/this._drag.y. The values passed along to eve("raphael.drag.start.", ...) were e.clientX + scrollX/e.clientY + scrollY which are the initial pre-corrected values. With this PR, the corrected values this._drag.x/this._drag.y are passed instead, which fixes the behavior for touch drags.

We ran into this in our application CODAP where we fixed it in our local embedded copy of Raphael in CODAP PR #223.