0
我創建了帶有可滾動背景的Kineticjs場景。在這個背景之上是一個帶有事件監聽器的矩形。我的問題是,在移動背景並繪製場景後,可能會導致此事件偵聽器無法觸發。我不知道它可能是什麼,我甚至打電話給.moveToTop()
,看看我是否可以將形狀移回到頂端,即使我非常確定它仍然存在。那麼什麼可能導致事件監聽器在平局之後停止發射?Kineticjs:事件偵聽器在繪製後丟失
有沒有人知道這個問題的解決方法?我想我可能可以將另一個事件監聽器附加到該形狀,但如果我正在做一些根本性錯誤,這似乎沒有必要。
在此先感謝!
編輯:這是一些代碼。
// Here is the event listener attached to scroll bar
hscroll4.on('dragmove', updateBackgroundPos4);
// Here is code to move background
var updateBackgroundPos4 = function() {
var hscrollPos = hscroll4.getX();
console.log("mb4: ", mainBody4Dynamic.getX());
mainDynamicWrapper.setX(-hscrollPos+120); //the BG I am moving on scroll
// my attempt at getting it to work
dynamicLayer4.moveToTop();
mainBody4.moveToTop();
mainDynamicWrapper.moveToTop();
newFolder.moveToTop();
dynamicLayer4.draw();
//stage4.drawHit();
};
// Here is the group which contains the rectangle
folderGroup.on('mouseover', function() { //---- this isn't firing after draw
document.body.style.cursor = 'pointer';
console.log("change text");
updateTestText();
});
folderGroup.on('mouseout', function() {
document.body.style.cursor = 'default';
});
編輯2:即使我的建議不起作用。添加事件偵聽器背面不讓它再次點擊:(
你能提供一個小提琴嗎?或者至少顯示一些代碼? –
我附上了一些代碼。我將不得不大量修改代碼來創建一個小提琴,所以我希望我已經足夠了。 –