Created
June 7, 2021 20:53
-
-
Save GoodBoyNinja/7c2156e13cce1f25c34f04f3263f1fc1 to your computer and use it in GitHub Desktop.
pass a layer to freeze it where the time indicator currently is. Pass a specific time (in seconds) to freeze somewhere else.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function freezeLayerAtCurrentTime(layer, specificTime) { | |
if (!layer) { | |
// no layer | |
return false | |
}; | |
try{ | |
layer.timeRemapEnabled = true; | |
var timeRemapProp = layer("ADBE Time Remapping"); | |
var container = layer.containingComp || null; | |
if (!container) { | |
//container comp not found | |
return false | |
} | |
var time = (specificTime && !isNaN(specificTime)) ? specificTime : container.time; | |
timeRemapProp.setValueAtTime(time ,timeRemapProp.valueAtTime(time, false) ); | |
// remove first and last keys | |
var keysAmount = timeRemapProp.numKeys; | |
if (keysAmount == 3) { | |
timeRemapProp.removeKey(3); | |
timeRemapProp.removeKey(1); | |
// Freeze Seems Successful | |
return true; | |
}; | |
}catch(e){ | |
// something went wrong, you could print or alert the error | |
} | |
return false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment