caleb531 / jcanvas

A jQuery plugin that makes the HTML5 canvas easy to work with.
https://projects.calebevans.me/jcanvas/
MIT License
626 stars 192 forks source link

"offset is null" error when $(event.target).offset() returns null #8

Closed edoceo closed 12 years ago

edoceo commented 12 years ago

Using Firefox 10 on 64bit Linux I got this error. The event that creates the issue for me is a resize; which has no offset.

So, line 1102 should check that offset is a real value before reading it

// Currently:

var offset = $(event.target).offset();
event.offsetX = event.pageX - offset.left;
event.offsetY = event.pageY - offset.top;

// Fixed it with:

var offset = $(event.target).offset();
if (offset) {
    event.offsetX = event.pageX - offset. 
    event.offsetY = event.pageY - offset.top;
}
caleb531 commented 12 years ago

Thanks. I will add that fix for the next release. :)

-Caleb

On Tue, Feb 28, 2012 at 10:25 AM, edoceo < reply@reply.github.com

wrote:

Using Firefox 10 on 64bit Linux I got this error. The event that creates the issue for me is a resize; which has no offset.

So, line 1102 should check that offset is a real value before reading it

// Currently:

var offset = $(event.target).offset();
event.offsetX = event.pageX - offset.left;
event.offsetY = event.pageY - offset.top;

// Fixed it with:

var offset = $(event.target).offset();
if (offset) {
   event.offsetX = event.pageX - offset.
   event.offsetY = event.pageY - offset.top;
}

Reply to this email directly or view it on GitHub: https://github.com/caleb531/jcanvas/issues/8