From aff1f7ccb6abbc5d2ebd08b843db5ec9bdfa8d80 Mon Sep 17 00:00:00 2001 From: Joren Dandois Date: Sat, 4 Jul 2020 02:33:19 +0200 Subject: [PATCH] Disable move when locked Disable shift move when locked --- src/js/controller/DrawingController.js | 10 ++++++++++ src/js/tools/ToolsHelper.js | 3 +++ 2 files changed, 13 insertions(+) diff --git a/src/js/controller/DrawingController.js b/src/js/controller/DrawingController.js index 0ed1f055..e18aa244 100644 --- a/src/js/controller/DrawingController.js +++ b/src/js/controller/DrawingController.js @@ -137,6 +137,11 @@ }; ns.DrawingController.prototype.onTouchstart_ = function (event) { + var index = this.piskelController.getCurrentLayerIndex(); + var layer = this.piskelController.getLayerByIndex(index); + if (layer.locked) { + return; + } this.onMousedown_(event); }; @@ -153,6 +158,11 @@ * @private */ ns.DrawingController.prototype.onMousedown_ = function (event) { + var index = this.piskelController.getCurrentLayerIndex(); + var layer = this.piskelController.getLayerByIndex(index); + if (layer.locked) { + return; + } $.publish(Events.MOUSE_EVENT, [event, this]); var frame = this.piskelController.getCurrentFrame(); var coords = this.getSpriteCoordinates(event.clientX, event.clientY); diff --git a/src/js/tools/ToolsHelper.js b/src/js/tools/ToolsHelper.js index 8f9766a6..ac4f66a4 100644 --- a/src/js/tools/ToolsHelper.js +++ b/src/js/tools/ToolsHelper.js @@ -16,6 +16,9 @@ ns.ToolsHelper = { var currentFrameIndex = pskl.app.piskelController.getCurrentFrameIndex(); var layers = useAllLayers ? pskl.app.piskelController.getLayers() : [pskl.app.piskelController.getCurrentLayer()]; return layers.reduce(function (previous, layer) { + if (layer.locked) { + return previous; + } var frames = useAllFrames ? layer.getFrames() : [layer.getFrameAt(currentFrameIndex)]; return previous.concat(frames); }, []);