canvas-editor-engine 2.3.50 → 2.3.52
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs
CHANGED
@@ -2555,17 +2555,32 @@ var DrawLayersService = function() {
|
|
2555
2555
|
message: "Layer not found"
|
2556
2556
|
});
|
2557
2557
|
var layer = _this.layerList[layerIndex];
|
2558
|
+
var newOrder = layer.order;
|
2558
2559
|
if (options === null || options === void 0 ? void 0 : options.to) {
|
2559
|
-
|
2560
|
+
newOrder = options.to;
|
2560
2561
|
}
|
2561
2562
|
if (options === null || options === void 0 ? void 0 : options.direction) {
|
2562
2563
|
switch (options.direction) {
|
2563
2564
|
case "up":
|
2564
|
-
|
2565
|
+
newOrder = layer.order + 1;
|
2565
2566
|
break;
|
2566
2567
|
|
2567
2568
|
case "down":
|
2568
|
-
|
2569
|
+
newOrder = layer.order - 1;
|
2570
|
+
break;
|
2571
|
+
|
2572
|
+
case "front":
|
2573
|
+
var mostMax = _this.layerList.sort((function(a, b) {
|
2574
|
+
return a.order - b.order;
|
2575
|
+
}))[0];
|
2576
|
+
newOrder = mostMax.order;
|
2577
|
+
break;
|
2578
|
+
|
2579
|
+
case "back":
|
2580
|
+
var mostMin = _this.layerList.sort((function(a, b) {
|
2581
|
+
return b.order - a.order;
|
2582
|
+
}))[0];
|
2583
|
+
newOrder = mostMin.order;
|
2569
2584
|
break;
|
2570
2585
|
}
|
2571
2586
|
}
|
@@ -2573,15 +2588,27 @@ var DrawLayersService = function() {
|
|
2573
2588
|
var operation = options.addendum.operation;
|
2574
2589
|
var operand = options.addendum.value;
|
2575
2590
|
if (operation === "add") {
|
2576
|
-
|
2591
|
+
newOrder = layer.order + operand;
|
2577
2592
|
} else if (operation === "subtract") {
|
2578
|
-
|
2593
|
+
newOrder = layer.order - operand;
|
2579
2594
|
} else if (operation === "multiplication") {
|
2580
|
-
|
2595
|
+
newOrder = layer.order * operand;
|
2581
2596
|
} else if (operation === "division") {
|
2582
|
-
|
2597
|
+
newOrder = layer.order / operand;
|
2583
2598
|
}
|
2584
2599
|
}
|
2600
|
+
var replaceableIndex = _this.layerList.findIndex((function(layer) {
|
2601
|
+
return layer.order === newOrder;
|
2602
|
+
}));
|
2603
|
+
if (replaceableIndex === -1) return reject({
|
2604
|
+
status: "error",
|
2605
|
+
message: "Replaceable layer not found"
|
2606
|
+
});
|
2607
|
+
var replaceable = _this.layerList[replaceableIndex];
|
2608
|
+
replaceable.order = layer.order;
|
2609
|
+
_this.layerList[replaceableIndex] = replaceable;
|
2610
|
+
_this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", replaceable);
|
2611
|
+
layer.order = newOrder;
|
2585
2612
|
_this.layerList[layerIndex] = layer;
|
2586
2613
|
_this.appStoreRepository.store.drawLayersState.reduce("UPDATE_LAYER", layer);
|
2587
2614
|
resolve({
|
@@ -19,5 +19,14 @@ export default class DrawLayersService {
|
|
19
19
|
removePainter(id: IPainter['id']): void;
|
20
20
|
updatePainterData(painter: Painter): void;
|
21
21
|
removeLayer(id: ILayer['id']): Promise<unknown>;
|
22
|
+
/**
|
23
|
+
* options steps:
|
24
|
+
* 1. to (optional)
|
25
|
+
* 2. direction (optional)
|
26
|
+
* 3. addendum (optional)
|
27
|
+
* @param id ILayer['id']
|
28
|
+
* @param options IUpdateLayerOptions
|
29
|
+
* @returns promise { status: 'success' | 'error', message: string }
|
30
|
+
*/
|
22
31
|
changeLayerOrder(id: ILayer['id'], options: IUpdateLayerOptions): Promise<unknown>;
|
23
32
|
}
|
@@ -13,7 +13,7 @@ export interface ILayerUpdate {
|
|
13
13
|
export type TReducerNames = 'SET_LAYERS' | 'UPDATE_LAYER' | 'ADD_LAYER' | 'REMOVE_LAYER';
|
14
14
|
export interface IUpdateLayerOptions {
|
15
15
|
to?: number;
|
16
|
-
direction?: 'up' | 'down';
|
16
|
+
direction?: 'up' | 'down' | 'front' | 'back';
|
17
17
|
addendum?: {
|
18
18
|
operation: 'add' | 'subtract' | 'multiplication' | 'division';
|
19
19
|
value: number;
|