-
Using sourceRectAtTime and if/else
Hello,
I’m new here and trying to figure out how to combine the use of sourceRectAtTime with if/else.
I have two text layers on top of a shape layer. I’d like the shape layer width to adjust based on whichever text layer has the greatest width. Below is the expression I’ve written and I am not getting any errors, but the if/else statement doesn’t seem to be working. The shape layer adjusts based on the first text layer, but if the second text layer is greater than the first, it does not adjust accordingly. Any help would be greatly appreciated. Thank you.
Chris Stetson
var A = thisComp.layer("NAME");
var W1 = A.sourceRectAtTime().width;
var B = thisComp.layer("Title");
var W2 = B.sourceRectAtTime().width;
var Y = content("Rectangle 1").content("Rectangle Path 1").size[1]
var P = thisComp.layer("Control").effect("Text Padding")("Slider");if(W1>W2){
W1
}else{
W2
}[W1||W2,Y]+[P+P];
