fix issue that caused delayed and broken resizing

This commit is contained in:
Jeff Nusz 2017-03-14 16:29:17 -07:00
parent d5b6178e33
commit dc6b6a388a
2 changed files with 7 additions and 5 deletions

View File

@ -605,7 +605,7 @@ common.extend(
}
},
onResizeDebounced: common.debounce(function() { this.onResize(); }, 200),
onResizeDebounced: common.debounce(function() { this.onResize(); }, 50),
/**
* Mark objects for saving. The order of these objects cannot change as

View File

@ -88,8 +88,9 @@ const Common = {
setTimeout(fnc, 0);
},
// call the function immediately, but wait until threshold passes to allow it to be called again
debounce: function(func, threshold) {
// if the function is called repeatedly, wait until threshold passes until we execute the function
debounce: function(func, threshold, callImmediately) {
let timeout;
return function() {
@ -97,14 +98,15 @@ const Common = {
const args = arguments;
function delayed() {
timeout = null;
if (!callImmediately) func.apply(obj, args);
}
const allowCall = !timeout;
const callNow = callImmediately || !timeout;
clearTimeout(timeout);
timeout = setTimeout(delayed, threshold);
if (allowCall) {
if (callNow) {
func.apply(obj, args);
}
};