Fixed mouse events

This commit is contained in:
Nathan Dinsmore 2014-02-19 22:53:32 -05:00
parent b2862696f0
commit 1112081a4f
2 changed files with 19 additions and 15 deletions

View file

@ -98,8 +98,9 @@ $(function() {
});
$('#container').mousemove(function(e) {
var absX = e.pageX - this.offsetLeft;
var absY = e.pageY - this.offsetTop;
var bb = this.getBoundingClientRect();
var absX = e.clientX - bb.left;
var absY = e.clientY - bb.top;
runtime.mousePos = [absX-240, -absY+180];
});
@ -127,8 +128,9 @@ $(function() {
$('#container').bind('touchmove', function(e) {
var touch = e.originalEvent.touches[0] || e.originalEvent.changedTouches[0];
var absX = touch.pageX - this.offsetLeft;
var absY = touch.pageY - this.offsetTop;
var bb = this.getBoundingClientRect();
var absX = touch.clientX - bb.left;
var absY = touch.clientY - bb.top;
runtime.mousePos = [absX-240, -absY+180];
});