diff options
author | Matthew Somerville <matthew@mysociety.org> | 2019-10-11 14:53:30 +0100 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2019-10-15 09:07:04 +0100 |
commit | 3550b5b2c0ca271a5505198a267ea8c9e94033f1 (patch) | |
tree | 8cec5eb1f31b3dfab638538d58fd53d412c7dca4 /web/js/map-OpenLayers.js | |
parent | 448a603594f598bd692fa402139357d945c60d15 (diff) |
Add map filter debouncing.
Diffstat (limited to 'web/js/map-OpenLayers.js')
-rw-r--r-- | web/js/map-OpenLayers.js | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/web/js/map-OpenLayers.js b/web/js/map-OpenLayers.js index 1588bda2e..eb62904b0 100644 --- a/web/js/map-OpenLayers.js +++ b/web/js/map-OpenLayers.js @@ -10,6 +10,19 @@ if (!Object.keys) { }; } +function debounce(fn, delay) { + var timeout; + return function() { + var that = this, args = arguments; + var debounced = function() { + timeout = null; + fn.apply(that, args); + }; + clearTimeout(timeout); + timeout = setTimeout(debounced, delay); + }; +} + var fixmystreet = fixmystreet || {}; fixmystreet.utils = fixmystreet.utils || {}; @@ -428,10 +441,10 @@ $.extend(fixmystreet.utils, { } } - function categories_or_status_changed() { + var categories_or_status_changed = debounce(function() { // If the category or status has changed we need to re-fetch map markers fixmystreet.markers.refresh({force: true}); - } + }, 1000); function replace_query_parameter(qs, id, key) { var value, |