Fixed mouse events
This commit is contained in:
parent
b2862696f0
commit
1112081a4f
2 changed files with 19 additions and 15 deletions
|
@ -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];
|
||||
});
|
||||
|
||||
|
|
Reference in a new issue