-
Notifications
You must be signed in to change notification settings - Fork 61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DomEvent _onMouseEvent/_onMouseMove error when Scroll #15
Comments
thanks for the report. I just noticed your solution imply depending on jquery. i would prefere to adding this dependancies to this bug. one without jquery would be better if possible |
is it ok to replace it with https://developer.mozilla.org/en/DOM/element.scrollLeft ? im not much of a frontend personn |
It's fine, i used jquery because it avoid some trouble ( http://help.dottoro.com/ljcjgrml.php ) Same remarks with Threex.WindowResize, it takes window as default, should be possible to add a domElement ? and then use it on callback function to set camera aspect & renderer size . thx, |
i tried to port it for 20 min with little success. could you do a pull request without jquery dependancy ? |
Hello,
First thanks for your lib.
About the issue :
When no scroll is set no problem, all works fine and mouse event fired on correct object.
But when canvas container is on a page, and page is scrolling a bug appears : Mouse position does not calculate correctly and a bad or no object is selected :
original code : OK in case domElement == window
var mouseX = +(domEvent.clientX / window.innerWidth ) * 2 - 1;
var mouseY = -(domEvent.clientY / window.innerHeight) * 2 + 1;
but KO if domElement != window
one possible solution for _onMouseEvent/_onMouseMove :
var mouseX = +((domEvent.clientX - this.domElement.offset().left + $(window).scrollLeft()) / this.domElement.width()) * 2 - 1;
var mouseY = -((domEvent.clientY - this.domElement.offset().top + $(window).scrollTop()) / this.domElement.height()) * 2 + 1;
Now ScrollLeft/Top are taken into consideration with domElement position.
PoP
The text was updated successfully, but these errors were encountered: