0
我有一個很好的整合傳單在我的網站,並希望有一個長期mousedown觸發多次的行動。 我嘗試了幾件事,無法讓它在我的自定義easybuttons或Leaflet縮放控件上工作。小冊子:如何啓用長時間點擊? (已經mousedown觸發多次按鈕)
任何人都可以幫忙嗎?
我在猜測Leaflet的javascript禁用多個操作,直到mouseup發生。我想刪除它。
謝謝
我有一個很好的整合傳單在我的網站,並希望有一個長期mousedown觸發多次的行動。 我嘗試了幾件事,無法讓它在我的自定義easybuttons或Leaflet縮放控件上工作。小冊子:如何啓用長時間點擊? (已經mousedown觸發多次按鈕)
任何人都可以幫忙嗎?
我在猜測Leaflet的javascript禁用多個操作,直到mouseup發生。我想刪除它。
謝謝
這是一個簡單的任務,涉及只是一個mousedown
和mouseup
事件處理程序,並setInterval
和clearInterval
一個電話:
function thingToDoWhenTheButtonIsPressed() {
console.log('something');
}
var mousedownInterval;
map.on('mousedown', function() {
mousedownInterval = setInterval(thingToDoWhenTheButtonIsPressed, 500);
});
map.on('mouseup', function() {
clearInterval(mousedownInterval);
});
你可以看到一個working example here。
不要忘記諮詢Leaflet documentation和MDN的documentation about window.setInterval()
和about window.clearInterval()
。