src/input/mouse.js in entityjs-0.3.1 vs src/input/mouse.js in entityjs-0.3.2

- old
+ new

@@ -49,36 +49,25 @@ }, event:function(e, extra){ //calculate mouse coordinate - var x; - var y; + var x = e.offsetX; + var y = e.offsetY; - if(e.pageX){ - x = e.pageX; - y = e.pageY; - } else { - x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; - y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; - } + var that = re.c('mouse'); - x -= re.sys.canvas.offsetLeft; - y -= re.sys.canvas.offsetTop; - - //ignore if off canvas - if(x < 0 || y < 0 || y > re.sys.sizeY || x > re.sys.sizeX){ - return; + /* + if(re.preventDefault && re.preventDefault.d[key]){ + e.preventDefault(); } + */ - var that = re.c('mouse'); - - //FUTURE automatically transform screen coordinates? var c, t, obj; for(var i=0; i<that.l.length; i++){ t = that.l[i]; - obj = {x:x, y:y}; + obj = {posX:x, posY:y}; obj.screenX = re.screen.toScreenX(x); obj.screenY = re.screen.toScreenY(y); t.trigger(e.type, obj, e); @@ -88,15 +77,16 @@ } }, i:function(){ - re.listener('mousedown', this.press, false); - re.listener('mouseup', this.press, false); - re.listener('mousemove', this.event, false); - re.listener('click', this.event, false); - re.listener('dblclick', this.event, false); - re.listener('contextmenu', this.event, false); + var c = re.sys.canvas; + re.listener('mousedown', this.press, c); + re.listener('mouseup', this.press, c); + re.listener('mousemove', this.event, c); + re.listener('click', this.event, c); + re.listener('dblclick', this.event, c); + re.listener('contextmenu', this.event, c); } }) .init(function(c){ //add to listener array \ No newline at end of file