digitalfruit/limejs — Issue #16: e.screenPosition does not take scrollOffset into account
Author: mediabytes
Created: 2011-10-13 10:11:03+00:00
State: open

Hi,

We are using a div as a parent container for the director class. And when the div is positioned at for example top: 1000px, and the user need to scroll down to start playing the game, the e.screenPostion does not take scrollOffset into account. So, all the buttons and sprites do not respond to the click event because of the hitTest method using e.screenPosition.

I've found a fix for this @ http://www.quirksmode.org/js/events_properties.html and added it to events/eventdispatcher.js.

starting at line 135:

else {
// screenPosition does not take scrollOffset into account!
//ee.screenPosition = new goog.math.Coordinate(e.clientX, e.clientY);
var posx = 0;
var posy = 0;
if (!e) var e = window.event;
if (e.pageX || e.pageY)	{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)	{
posx = e.clientX + document.body.scrollLeft
+ document.documentElement.scrollLeft;
posy = e.clientY + document.body.scrollTop
+ document.documentElement.scrollTop;
}
ee.screenPosition = new goog.math.Coordinate(posx, posy);
doBreak = 1;
}

Is there a way to overwrite this function in our application? Or should this be added to the limejs core?

Thank you & keep up the good work!

Wouter