Hi Edward! I’m not a pro with scripts but I think that instead of starting an undo group on onChanging and closing it on onChange, you can use the app.beginUndoGroup() and app.endUndoGroup() methods to manually start and end an undo group at the appropriate times.
Here’s an example implementation:
var undoGroupInProgress = false;
slider1.onChanging = function() {
if (!undoGroupInProgress) {
app.beginUndoGroup("Preview Slider Change");
undoGroupInProgress = true;
}
// create shape layer to preview (adjust outPoint on the shape layer)
}
slider1.onChange = function() {
// apply the effect
if (undoGroupInProgress) {
app.endUndoGroup();
undoGroupInProgress = false;
}
}
With this implementation, the undo group is only started once when the slider is first changed, and is ended once when the slider is released. The undoGroupInProgress variable is used to ensure that the undo group is only closed if it was actually opened in the first place.
This should avoid the “undo mismatch” warning and provide a clean undo history for your users.
Hope this helps/work for you.