improve refresh handling
- increase timeout on zoom/move end to 0.8 seconds - prevent repeated refreshes faster than every 5 seconds - delay initial refresh on load - should prevent immediate refresh after page load fix #200
This commit is contained in:
12
code/boot.js
12
code/boot.js
@ -226,14 +226,16 @@ window.setupMap = function() {
|
||||
|
||||
// update map hooks
|
||||
map.on('movestart zoomstart', window.requests.abort);
|
||||
map.on('moveend zoomend', function() { window.startRefreshTimeout(500) });
|
||||
|
||||
// run once on init
|
||||
window.requestData();
|
||||
window.startRefreshTimeout();
|
||||
map.on('moveend zoomend', function() { console.log('map moveend'); window.startRefreshTimeout(ON_MOVE_REFRESH*1000) });
|
||||
|
||||
window.addResumeFunction(window.requestData);
|
||||
window.requests.addRefreshFunction(window.requestData);
|
||||
|
||||
// start the refresh process with a small timeout, so the first data request happens quickly
|
||||
// (the code originally called the request function directly, and triggered a normal delay for the nxt refresh.
|
||||
// however, the moveend/zoomend gets triggered on map load, causing a duplicate refresh. this helps prevent that
|
||||
window.startRefreshTimeout(ON_MOVE_REFRESH*1000);
|
||||
|
||||
};
|
||||
|
||||
// renders player details into the website. Since the player info is
|
||||
|
Reference in New Issue
Block a user