Merge pull request #847 from Ni-zav/fix/816-script-transform-shortcuts-s20261011T141200Z-fd2e

fix(script): expose AVLayer transform property shortcuts

# Conflicts:
#	crates/script/src/tests.rs
This commit is contained in:
Brandon Thomas committed 2026-10-12 03:23:21 -04:00
commit 255d888236
2 files changed
+25

No files matched your search

+5
View File
@@ -1187,6 +1187,11 @@ AVLayer.prototype.constructor = AVLayer;
var P = AVLayer.prototype;
function def(name, get, set) { Object.defineProperty(P, name, { get: get, set: set }); }
def("source", function () { return __item(this.__info().source); });
// After Effects exposes the most common Transform properties directly on AVLayer.
// Return the original Property object, not its current value: scripts can keyframe it.
["anchorPoint", "position", "scale", "rotation", "opacity"].forEach(function (name) {
def(name, function () { return this.transform[name]; });
});
def("width", function () { return this.__info().width; });
def("height", function () { return this.__info().height; });
def("threeDLayer", function () { return this.__info().threeDLayer; }, function (v) { this.__switch("threeD", v); });
+20
View File
@@ -859,3 +859,23 @@ fn script_layer_comment_and_unnamed_marker_params_round_trip() {
);
assert_eq!(o.result, json!(["Saved layer note", "1", "", "2"]));
}
#[test]
fn script_av_layer_transform_shortcuts_return_live_properties() {
let mut s = session();
let o = ok(
&mut s,
r#"
var c = app.project.items.addComp("Shortcuts", 100, 100, 1, 5, 25);
var l = c.layers.addSolid([1, 0, 0], "S", 10, 10, 1);
l.position.setValue([30, 40]);
l.rotation.setValueAtTime(1, 45);
[l.position.value[0], l.transform.position.value[1], l.rotation.numKeys,
l.opacity === undefined, l.scale === undefined, l.anchorPoint === undefined]
"#,
);
assert_eq!(o.result, json!([30, 40, 1, false, false, false]));
s.undo();
let restored = ok(&mut s, "app.project.item(1).layer(1).rotation.numKeys");
assert_eq!(restored.result, json!(0));
}