willowsystems / jSignature

jQuery plugin - draw signature in browser.
720 stars 266 forks source link

Wrong cordinates in Opera mobile #18

Open bertrandmc opened 11 years ago

bertrandmc commented 11 years ago

Hi people, I Just found a bug with Opera mobile when scrolling is necessary to reach the canvas.

The getPointFromEvent function is using firstEvent.pageY to calculate the point but It should be using firstEvent.clientY instead. This is happening only with Opera Mobile.

My quick fix was:

//this is a hack due to Opera Mobile wrong coordinate in pageY
//if it is Opera use clientY instead
var page_Y = (navigator.userAgent.search('Opera Mobi')) ? firstEvent.clientY :  firstEvent.pageY;

return new Point(
    Math.round(firstEvent.pageX + shiftX)
    , Math.round(page_Y + shiftY) + jSignatureInstance.fatFingerCompensation
)

Thanks for the plugin, it's great! Bema