我使用'piggyback'来捕捉对象:这里提到的悬停事件:https://github.com/kangax/fabric.js/wiki/Working-with-events
假设标准设置和这些事件:
canvas.on('object:over', function(e) {
// some manipulation with e.target here, will execute on hover as expected
canvas.renderAll.bind(canvas);
});
canvas.on('after:render', function() {
// code here wont execute on hover but only after other action which evokes render, such as click and drag of object
})
还有其他方法强制在鼠标悬停对象时重新渲染画布吗?
如果你想知道我的目标是什么,我想突出鼠标上的物体,非常类似于这样:http://www.html5canvastutorials.com/demos/labs/html5-canvas-world-map-svg-path-with-kineticjs/index.php
非常感谢您的帮助!