From: Josep LlodrĂ  Date: Wed, 25 Jan 2012 10:48:23 +0000 (+0100) Subject: event.offsetX and Y fixed for Firefox in interaction.js X-Git-Tag: v1.0.0~334^2 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=417af431300573b3069ddcb9b9b26cd3cb40c051;p=dygraphs.git event.offsetX and Y fixed for Firefox in interaction.js --- diff --git a/tests/interaction.js b/tests/interaction.js index ced5aef..c98c445 100644 --- a/tests/interaction.js +++ b/tests/interaction.js @@ -62,6 +62,12 @@ function offsetToPercentage(g, offsetX, offsetY) { function dblClickV3(event, g, context) { // Reducing by 20% makes it 80% the original size, which means // to restore to original size it must grow by 25% + + if (!(event.offsetX && event.offsetY)){ + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + var percentages = offsetToPercentage(g, event.offsetX, event.offsetY); var xPct = percentages[0]; var yPct = percentages[1]; @@ -89,6 +95,11 @@ function scrollV3(event, g, context) { // that verbatim, it would be a 7.5%. var percentage = normal / 50; + if (!(event.offsetX && event.offsetY)){ + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + var percentages = offsetToPercentage(g, event.offsetX, event.offsetY); var xPct = percentages[0]; var yPct = percentages[1];