I can animate an object and then add a mouse:over
event.
var canvas = new fabric.Canvas('c');
var x1 = 5;
var y1 = 5;
var x2 = 100;
var y2 = 100;
var rect = new fabric.Rect({
width: 10,
height: 10,
left: x1,
top: y1,
stroke: '#000',
strokeWidth: 2,
fill: '#faa',
selectable: false
});
canvas.add(rect);
rect.animate({
'left': x2,
'top': y2
}, {
duration: 10000,
onChange: canvas.renderAll.bind(canvas),
onComplete: function() {
}
});
canvas.on('mouse:over', function (e) {
console.log('mouseover');
});
<canvas id="c"></canvas>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.6.3/fabric.min.js"></script>
However the mouse:over
event continues to fire from the rectangle's original position. Once the animate finishes then the mouse:over
event works again over the animated object.
Is it possible to have a mouse:over
event fire while an object is moving/animating?