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:
Jon Atkins
2013-05-01 01:57:02 +01:00
parent 19638dfc39
commit 308459178d
3 changed files with 33 additions and 11 deletions

View File

@ -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