From fd17b4a2787c2035f76915d852b24c3efe3393c1 Mon Sep 17 00:00:00 2001 From: Jon Atkins Date: Fri, 21 Feb 2014 16:35:48 +0000 Subject: [PATCH] portal-names - use different delays for data loading updates and user events - improves performance --- plugins/portal-names.user.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/plugins/portal-names.user.js b/plugins/portal-names.user.js index d6ba283c..74322119 100644 --- a/plugins/portal-names.user.js +++ b/plugins/portal-names.user.js @@ -150,13 +150,13 @@ window.plugin.portalNames.updatePortalLabels = function() { // ass calculating portal marker visibility can take some time when there's lots of portals shown, we'll do it on // a short timer. this way it doesn't get repeated so much -window.plugin.portalNames.delayedUpdatePortalLabels = function() { +window.plugin.portalNames.delayedUpdatePortalLabels = function(wait) { if (window.plugin.portalNames.timer === undefined) { window.plugin.portalNames.timer = setTimeout ( function() { window.plugin.portalNames.timer = undefined; window.plugin.portalNames.updatePortalLabels(); - }, 0.5*1000); + }, wait*1000); } } @@ -168,9 +168,9 @@ var setup = function() { window.plugin.portalNames.labelLayerGroup = new L.LayerGroup(); window.addLayerGroup('Portal Names', window.plugin.portalNames.labelLayerGroup, true); - window.addHook('requestFinished', window.plugin.portalNames.delayedUpdatePortalLabels); - window.addHook('mapDataRefreshEnd', window.plugin.portalNames.delayedUpdatePortalLabels); - window.map.on('overlayadd overlayremove', window.plugin.portalNames.delayedUpdatePortalLabels); + window.addHook('requestFinished', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(3.0);},1); }); + window.addHook('mapDataRefreshEnd', function() { window.plugin.portalNames.delayedUpdatePortalLabels(0.5); }); + window.map.on('overlayadd overlayremove', function() { setTimeout(function(){window.plugin.portalNames.delayedUpdatePortalLabels(1.0);},1); }); } // PLUGIN END //////////////////////////////////////////////////////////