diff --git a/web/js/imageFeed.js b/web/js/imageFeed.js index 927c199..d02d8a1 100644 --- a/web/js/imageFeed.js +++ b/web/js/imageFeed.js @@ -285,7 +285,8 @@ app.registerExtension({ feedLocation.value = e.target.value; imageFeed.className = `pysssss-image-feed pysssss-image-feed--${feedLocation.value}`; updateMenuParent(feedLocation.value); - window.dispatchEvent(new Event("resize")); + saveVal("Location", feedLocation.value); + window.dispatchEvent(new Event("resize")); }, }, ["left", "top", "right", "bottom", "hidden"].map((m) => @@ -303,10 +304,13 @@ app.registerExtension({ if (value === "hidden") { imageFeed.remove(); if (showMenuButton) { - showMenuButton.element.style.display = "none"; + requestAnimationFrame(() => { + showMenuButton.element.style.display = "none"; + }); } showButton.style.display = "none"; } else { + showMenuButton.element.style.display = "unset"; showButton.style.display = visible ? "none" : "unset"; imageFeed.className = `pysssss-image-feed pysssss-image-feed--${value}`; updateMenuParent(value); diff --git a/web/js/snapToGrid.js b/web/js/snapToGrid.js deleted file mode 100644 index 07d5aa8..0000000 --- a/web/js/snapToGrid.js +++ /dev/null @@ -1,73 +0,0 @@ -import { app } from "../../../scripts/app.js"; - -let setting; -const id = "pysssss.SnapToGrid"; - -/** Wraps the provided function call to set/reset shiftDown when setting is enabled. */ -function wrapCallInSettingCheck(fn) { - if (setting?.value) { - const shift = app.shiftDown; - app.shiftDown = true; - const r = fn(); - app.shiftDown = shift; - return r; - } - return fn(); -} - -const ext = { - name: id, - init() { - setting = app.ui.settings.addSetting({ - id, - name: "🐍 Always snap to grid", - defaultValue: false, - type: "boolean", - onChange(value) { - app.canvas.align_to_grid = value; - }, - }); - - // We need to register our hooks after the core snap to grid extension runs - // Do this from the graph configure function so we still get onNodeAdded calls - const configure = LGraph.prototype.configure; - LGraph.prototype.configure = function () { - // Override drawNode to draw the drop position - const drawNode = LGraphCanvas.prototype.drawNode; - LGraphCanvas.prototype.drawNode = function () { - wrapCallInSettingCheck(() => drawNode.apply(this, arguments)); - }; - - // Override node added to add a resize handler to force grid alignment - const onNodeAdded = app.graph.onNodeAdded; - app.graph.onNodeAdded = function (node) { - const r = onNodeAdded?.apply(this, arguments); - const onResize = node.onResize; - node.onResize = function () { - wrapCallInSettingCheck(() => onResize?.apply(this, arguments)); - }; - return r; - }; - - - const groupMove = LGraphGroup.prototype.move; - LGraphGroup.prototype.move = function(deltax, deltay, ignore_nodes) { - wrapCallInSettingCheck(() => groupMove.apply(this, arguments)); - } - - const canvasDrawGroups = LGraphCanvas.prototype.drawGroups; - LGraphCanvas.prototype.drawGroups = function (canvas, ctx) { - wrapCallInSettingCheck(() => canvasDrawGroups.apply(this, arguments)); - } - - const canvasOnGroupAdd = LGraphCanvas.onGroupAdd; - LGraphCanvas.onGroupAdd = function() { - wrapCallInSettingCheck(() => canvasOnGroupAdd.apply(this, arguments)); - } - - return configure.apply(this, arguments); - }; - }, -}; - -app.registerExtension(ext);