doujiaoben28596 2014-03-28 06:01
浏览 17

javascript绘制在页面中间的画布上没有正确检测高度

I'll start off by saying feel free to edit the title, as i don't know what to call it.I am trying to make a small image editor for a game(Flappy loach) And I have the following so far: http://joeybabcock.me/tests/php/7.php However, when I try to get the client's mouse position, it doesn't seem to work. it is centered using :

 position: fixed;
 top: 50%;
 left: 50%;
 margin-top: -32px;
 margin-left: -32px;

For css and for the javascript detecting the position:

function logClick(e) {
console.log('click at X='+ (screen.availWidth - (Math.ceil(e.clientX / 2)))+'Y='+(screen.availHeight - (Math.ceil(e.clientY / 2))));
}

Log click is called by: canvar.addEventListener('mouseout', logClick); What I want it to say, is when I mouse over the brown square's left top corner it should say X=0, Y=0, and if I mouse over the bottom right, it would say, X=64, Y=64. Thanks for any help.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀
    • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类