【发布时间】:2014-10-16 08:28:38
【问题描述】:
我正在使用 Google 闭包库并注册点击和鼠标移动事件。我得到了点击事件,但是鼠标移动事件没有出现。这是 Chrome 浏览器观察到的,在 Firefox 中得到相同的事件
<canvas id='canvas1' width="512px" height="512px" style='top:0px;right:0px;' > </canvas>
MyTest.virtualCanvas = function(){
this.destCanvas = document.getElementById('canvas1');
this.destCtx = this.destCanvas.getContext('2d');
this.getCallBackFn = this.highContrastFn.bind(this);
this.mouseMoveBackFn = this.mouseMoveCB.bind(this);
goog.events.listen(this.destCanvas, goog.events.EventType.CLICK, this.getCallBackFn);
goog.events.listen(this.destCanvas, goog.events.EventType.MOUSEMOVE, this.mouseMoveBackFn);
};
MyTest.virtualCanvas.prototype.mouseMoveCB = function(evt){
var x = evt.offsetX;
var y = evt.offsetY;
}
MyTest.virtualCanvas.prototype.highContrastFn = function(evt){
var x = evt.offsetX;
var y = evt.offsetY;
}
【问题讨论】:
标签: javascript dom-events google-closure-library