mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
fix issue that caused delayed and broken resizing
This commit is contained in:
parent
d5b6178e33
commit
dc6b6a388a
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user