Unexpected Double Movement of Selected Layers in UXP Script
I have created the following UXP code. This code is intended to move the selected layers by a specified amount. When I run this code with multiple layers (Layer A, Layer B) selected, I expect that Layer A will move by (-100, -20) from its current position, and then Layer B will move by (-100, -20) from its current position. However, in reality, both Layer A and Layer B are moved by (-100, -20) twice.
In the for loop, I expected the layers to move individually, but it seems that all selected layers are being moved together in each iteration. Is this behavior normal? How can I avoid this issue?
--------------
const { app, core } = require("photoshop");
async function testplay() {
await core.executeAsModal(async () => {
const doc = app.activeDocument;
const layers = doc.activeLayers;
for (const layer of layers) {
await layer.translate(100, 10);
}
}, { commandName: 'Test Translate' });
}