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
|
* Mark objects for saving. The order of these objects cannot change as
|
||||||
|
@ -88,8 +88,9 @@ const Common = {
|
|||||||
setTimeout(fnc, 0);
|
setTimeout(fnc, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
// call the function immediately, but wait until threshold passes to allow it to be called again
|
// if the function is called repeatedly, wait until threshold passes until we execute the function
|
||||||
debounce: function(func, threshold) {
|
debounce: function(func, threshold, callImmediately) {
|
||||||
|
|
||||||
let timeout;
|
let timeout;
|
||||||
|
|
||||||
return function() {
|
return function() {
|
||||||
@ -97,14 +98,15 @@ const Common = {
|
|||||||
const args = arguments;
|
const args = arguments;
|
||||||
function delayed() {
|
function delayed() {
|
||||||
timeout = null;
|
timeout = null;
|
||||||
|
if (!callImmediately) func.apply(obj, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
const allowCall = !timeout;
|
const callNow = callImmediately || !timeout;
|
||||||
|
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
timeout = setTimeout(delayed, threshold);
|
timeout = setTimeout(delayed, threshold);
|
||||||
|
|
||||||
if (allowCall) {
|
if (callNow) {
|
||||||
func.apply(obj, args);
|
func.apply(obj, args);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user