javascript - Canvas Kineticjs - position mouse is wrong -
i have text line @ first after have canvas
position mouse on canvas it's wrong (zero of y position = height of text line)
http://jsfiddle.net/dsc26/
<div id="output">output</div> <div id="container"></div> yoda.on('mousemove', function(e) { $('#output').html('position mouse on canvas: '+'x: ' + e.clientx + ', y: ' + e.clienty); });
how can fix that, thanks!.
you can use event.offsetx/y
or event.layerx/y
properties.
have here -> http://jsfiddle.net/dsc26/2/
yoda.on('mousemove', function(e) { var offsetx = e.offsetx || e.layerx, offsety = e.offsety || e.layery; $('#output').html('position mouse on canvas: '+'x: ' + offsetx + ', y: ' + offsety); });
Comments
Post a Comment