diff --git a/src/gui/layerGroup.js b/src/gui/layerGroup.js index 83f5260041..f6778e6f16 100644 --- a/src/gui/layerGroup.js +++ b/src/gui/layerGroup.js @@ -344,6 +344,7 @@ export class LayerGroup { return this.#baseScale; } + /** * Get the added scale: the scale added to the base scale. * @@ -439,11 +440,20 @@ export class LayerGroup { * @returns {ViewLayer|undefined} The layer. */ getBaseViewLayer() { - let layer; - if (this.#layers[0] instanceof ViewLayer) { - layer = this.#layers[0]; + // use first layer as base for calculating position and + // line sizes + let baseLayer; + for (const layer of this.#layers) { + if (layer instanceof ViewLayer) { + baseLayer = layer; + break; + } } - return layer; + if (typeof baseLayer === 'undefined') { + logger.warn('No layer found'); + return; + } + return baseLayer; } /** diff --git a/src/gui/stage.js b/src/gui/stage.js index e15f90baeb..0487335eea 100644 --- a/src/gui/stage.js +++ b/src/gui/stage.js @@ -140,9 +140,10 @@ export class OpacityBinder { if (typeof event.dataid === 'undefined') { return; } - // propagate to first view layer + // propagate to first view layer if it is not base layer const viewLayers = layerGroup.getViewLayersByDataId(event.dataid); - if (viewLayers.length !== 0) { + const baseLayer = layerGroup.getBaseViewLayer(); + if (viewLayers.length !== 0 && baseLayer !== viewLayers[0]) { viewLayers[0].setOpacity(event.value); viewLayers[0].draw(); }