- var Xrel = X - this.offsetLeft - $(this).width()/2;
- var Yrel = Y - this.offsetTop - $(this).height()/2;
+ var Xrel = X - this.getBoundingClientRect().left - $(this).width()/2;
+ var Yrel = Y - this.getBoundingClientRect().top - $(this).height()/2;