var paper = Raphael(10,10,700,500);
var backGround = paper.rect(10,10,600,400);
backGround.attr("fill", "#FFFFCC");
backGround.mousedown(function(){
console.log("down");
backGround.mousemove(function () {
console.log("move");
});
});
backGround.mouseup(function () {
console.log("up");
event.preventDefault();
});
在mouseup事件被触发后,控制台日志'移动'仍在工作
答案 0 :(得分:0)
监听器被分配一次,然后始终被触发。你可能想设置一个标志:
var down = false;
backGround.mousedown(function(){
console.log("down");
down = true;
});
backGround.mouseup(function () {
console.log("up");
down = false;
});
backGround.mousemove(function () {
if(down){
console.log("move");
}
});