From 985e3c43f9646c9085030ce842f01c424cd4ddc2 Mon Sep 17 00:00:00 2001 From: Azgaar Date: Mon, 12 Jul 2021 23:20:34 +0300 Subject: [PATCH] throttle work done on zoom and brush drag --- main.js | 2 +- modules/ui/heightmap-editor.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/main.js b/main.js index 17447830..9d5f7904 100644 --- a/main.js +++ b/main.js @@ -2023,7 +2023,7 @@ const regenerateMap = debounce(function () { restoreLayers(); if (ThreeD.options.isOn) ThreeD.redraw(); if ($("#worldConfigurator").is(":visible")) editWorld(); -}, 500); +}, 1000); // clear the map function undraw() { diff --git a/modules/ui/heightmap-editor.js b/modules/ui/heightmap-editor.js index 053dc477..4cac39f3 100644 --- a/modules/ui/heightmap-editor.js +++ b/modules/ui/heightmap-editor.js @@ -573,6 +573,7 @@ function editHeightmap() { document.getElementById("brushesSliders").style.display = "none"; } + const dragBrushThrottled = throttle(dragBrush, 100); function toggleBrushMode(e) { if (e.target.classList.contains("pressed")) { exitBrushMode(); @@ -581,7 +582,7 @@ function editHeightmap() { exitBrushMode(); document.getElementById("brushesSliders").style.display = "block"; e.target.classList.add("pressed"); - viewbox.style("cursor", "crosshair").call(d3.drag().on("start", dragBrush)); + viewbox.style("cursor", "crosshair").call(d3.drag().on("start", dragBrushThrottled)); } function dragBrush() {