I’ll try to explain:
The for loop starts at the current time, and steps back in time 1 frameDuration per loop until we are at time 0 (the beginning of the comp)
At each time/frame we inspect the value of the property (valueAtTime).
If it is more than 100, that’s the condition to start out animation.
But if we would keep it at this, then the animation would only trigger at the last frame that’s >=100 (because we are looking backwards) we actually want to start our animation at the first frame where it was 100, not the last (for a run of consecutive frames that satisfy the condition).
So I remember that we’ve encountered a frame that was more than 100 by setting trigger to true, but the loop continues to the previous frame to inspect that value.
If we encounter a frame where the value is less than 100, the loop should also continue. Unless trigger is true, because that means we have now reached the end of consecutive frames that were triggering. We break out of the loop and the variable t now holds the time-value of 1 frame before our animation should trigger.
Triggering the animation in this case is then archived by looking at the value timeremapping had “t seconds ago”. Presumably the timeremapping has its default keyframes at the start of the layer that would playback the animation.
If t is 0 or less than 0, this means the loop where we we’re looking for values that were more than 100 was able to loop all the way through without finding a trigger. So we should return 0, so the timeremapping is frozen.
I hope this explanation didn’t over complicate matters. I’m not the best at breaking down code to English 🙂