From 1fe26f3103d177a212e266cc42e74310caea2641 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sun, 15 May 2022 14:40:38 +0200 Subject: [PATCH] save thickness settings for each tool in localstorage --- src/js/main.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/js/main.js b/src/js/main.js index fe4bf6b..b35831c 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -321,6 +321,11 @@ function initWhiteboard() { } else { $("#textboxBackgroundColorPickerBtn").hide(); } + let savedThickness = localStorage.getItem("item_thickness_" + activeTool); + if (savedThickness) { + whiteboard.setStrokeThickness(savedThickness); + $("#whiteboardThicknessSlider").val(savedThickness); + } }); // upload image button @@ -584,8 +589,17 @@ function initWhiteboard() { $("#whiteboardThicknessSlider").on("input", function () { if (ReadOnlyService.readOnlyActive) return; whiteboard.setStrokeThickness($(this).val()); + let activeTool = $(".whiteboard-tool.active").attr("tool"); + localStorage.setItem("item_thickness_" + activeTool, $(this).val()); }); + let activeTool = $(".whiteboard-tool.active").attr("tool"); + let savedThickness = localStorage.getItem("item_thickness_" + activeTool); + if (savedThickness) { + whiteboard.setStrokeThickness(savedThickness); + $("#whiteboardThicknessSlider").val(savedThickness); + } + // handle drag&drop var dragCounter = 0; $("#whiteboardContainer").on("dragenter", function (e) {