mirror of
https://github.com/stagehacks/Cue-View.git
synced 2026-08-09 07:43:39 +00:00
debounce .draw()
This commit is contained in:
+14
-6
@@ -100,13 +100,21 @@ module.exports.draw = function draw(device) {
|
||||
const d = device;
|
||||
const $deviceDrawArea = document.getElementById(`device-${d.id}-draw-area`);
|
||||
|
||||
if ($deviceDrawArea) {
|
||||
const scriptEl = $deviceDrawArea.contentWindow.document.createRange().createContextualFragment(generateBodyHTML(d));
|
||||
$deviceDrawArea.contentWindow.document.body.replaceChildren(scriptEl);
|
||||
} else {
|
||||
drawDeviceFrame(d.id);
|
||||
if (device.drawTimeout !== undefined) {
|
||||
clearTimeout(device.drawTimeout);
|
||||
}
|
||||
d.drawn = true;
|
||||
|
||||
d.drawTimeout = setTimeout(() => {
|
||||
if ($deviceDrawArea) {
|
||||
const scriptEl = $deviceDrawArea.contentWindow.document
|
||||
.createRange()
|
||||
.createContextualFragment(generateBodyHTML(d));
|
||||
$deviceDrawArea.contentWindow.document.body.replaceChildren(scriptEl);
|
||||
} else {
|
||||
drawDeviceFrame(d.id);
|
||||
}
|
||||
d.drawn = true;
|
||||
}, 200);
|
||||
};
|
||||
|
||||
module.exports.update = function update(device, type, data) {
|
||||
|
||||
Reference in New Issue
Block a user