feat(script): remove a range of keyframes in one command (#814)

This commit is contained in:
Nigel Ihza Firdausy
2026-10-11 21:25:13 +07:00
parent 9a7d3e7699
commit be2c73ece9
2 changed files with 33 additions and 0 deletions
+13
View File
@@ -843,6 +843,19 @@ Property.prototype.property = function () { return null; };
return __call(id, params);
};
P.removeKey = function (i) { this.__keyCmd(i, "keys.delete"); };
// EffectCraft extension: remove an inclusive range with one engine edit instead of
// cloning the project for every removed key. Indices are one-based as in removeKey.
P.removeKeys = function (first, last) {
var keys = this.__keys();
first = __num(first, "first key");
last = __num(last, "last key");
if (!Number.isInteger(first) || !Number.isInteger(last) || first < 1 || last < first || last > keys.length)
throw __err("removeKeys: key range is out of bounds");
var targets = [];
for (var i = first; i <= last; i++)
targets.push({ layer: this.__layer.__id, prop: this.__uid, index: i - 1 });
return __call("keys.delete", { comp: this.__layer.__comp, __keys: targets });
};
P.keyInInterpolationType = function (i) { return KeyframeInterpolationType[this.__key(i).inInterp]; };
P.keyOutInterpolationType = function (i) { return KeyframeInterpolationType[this.__key(i).outInterp]; };
// Values that don't interpolate (checkboxes, popups, text) only hold.