mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
Debounce onResize by 1s
Fixes terrible performance issues on IOS 8 Safari
This commit is contained in:
parent
41d1da8ce4
commit
743794f483
@ -469,6 +469,24 @@ define([
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
GUI.debounce = function (func, threshold) {
|
||||||
|
var timeout;
|
||||||
|
|
||||||
|
return function debounced () {
|
||||||
|
var obj = this, args = arguments;
|
||||||
|
function delayed () {
|
||||||
|
func.apply(obj, args);
|
||||||
|
timeout = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timeout) {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
|
timeout = setTimeout(delayed, threshold);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
GUI.CLASS_AUTO_PLACE = 'a';
|
GUI.CLASS_AUTO_PLACE = 'a';
|
||||||
GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';
|
GUI.CLASS_AUTO_PLACE_CONTAINER = 'ac';
|
||||||
GUI.CLASS_MAIN = 'main';
|
GUI.CLASS_MAIN = 'main';
|
||||||
@ -614,7 +632,7 @@ define([
|
|||||||
this.closed = true;
|
this.closed = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
onResize: function() {
|
onResize: GUI.debounce(function() {
|
||||||
|
|
||||||
var root = this.getRoot();
|
var root = this.getRoot();
|
||||||
|
|
||||||
@ -648,7 +666,7 @@ define([
|
|||||||
root.__closeButton.style.width = root.width + 'px';
|
root.__closeButton.style.width = root.width + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
}, 1000),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark objects for saving. The order of these objects cannot change as
|
* Mark objects for saving. The order of these objects cannot change as
|
||||||
|
Loading…
Reference in New Issue
Block a user