slightly optimize onZoom

This commit is contained in:
Azgaar 2022-05-12 23:54:19 +03:00
parent decfbc1337
commit aab27ca673
4 changed files with 25 additions and 12 deletions

View file

@ -6,7 +6,7 @@ modules.editors = true;
// restore default viewbox events
function restoreDefaultEvents() {
svg.call(zoom);
viewbox.style("cursor", "default").on(".drag", null).on("click", clicked).on("touchmove mousemove", moved);
viewbox.style("cursor", "default").on(".drag", null).on("click", clicked).on("touchmove mousemove", onMouseMove);
legend.call(d3.drag().on("start", dragLegendBox));
}

View file

@ -65,8 +65,8 @@ function showElementLockTip(event) {
}
}
const moved = debounce(mouseMove, 100);
function mouseMove() {
const onMouseMove = debounce(handleMouseMove, 100);
function handleMouseMove() {
const point = d3.mouse(this);
const i = findCell(point[0], point[1]); // pack cell id
if (i === undefined) return;

View file

@ -167,7 +167,7 @@ optionsContent.addEventListener("change", function (event) {
if (id === "zoomExtentMin" || id === "zoomExtentMax") changeZoomExtent(value);
else if (id === "optionsSeed") generateMapWithSeed("seed change");
else if (id === "uiSizeInput" || id === "uiSizeOutput") changeUIsize(value);
if (id === "shapeRendering") viewbox.attr("shape-rendering", value);
else if (id === "shapeRendering") setRendering(value);
else if (id === "yearInput") changeYear();
else if (id === "eraInput") changeEra();
else if (id === "stateLabelsModeInput") options.stateLabelsMode = value;
@ -543,9 +543,7 @@ function applyStoredOptions() {
const themeColor = localStorage.getItem("themeColor");
changeDialogsTheme(themeColor, transparency);
// set shape rendering
viewbox.attr("shape-rendering", shapeRendering.value);
setRendering(shapeRendering.value);
options.stateLabelsMode = stateLabelsModeInput.value;
}
@ -622,6 +620,10 @@ function randomizeCultureSet() {
changeCultureSet();
}
function setRendering(value) {
viewbox.attr("shape-rendering", value);
}
// generate current year and era name
function generateEra() {
if (!stored("year")) yearInput.value = rand(100, 2000); // current year