@@ -3952,10 +3952,19 @@ export function initSandboxRuntimeModular(): void {
39523952 ) ;
39533953 // A timeline a scene's animation drives (a tween of its time, as tweenFromTo makes) is the scene's too, unless
39543954 // another owner registered it. A timeline the script built after it returned, after a font wait, is known only so.
3955- const drivenBy = ( animation : SceneAnimation , ids : string [ ] ) : SceneAnimation [ ] => {
3956- const others = new Set < unknown > ( [ state . capturedTimeline , window . gsap ?. globalTimeline ] ) ;
3955+ // What is never a scene's own: the runtime's roots and the timelines other compositions registered.
3956+ const ownedElsewhere = ( ids : string [ ] ) : Set < unknown > => {
3957+ const others = new Set < unknown > ( [
3958+ state . capturedTimeline ,
3959+ window . gsap ?. globalTimeline ,
3960+ ...builtRoots ,
3961+ ] ) ;
39573962 for ( const [ id , timeline ] of Object . entries ( window . __timelines ?? { } ) )
39583963 if ( ! ids . includes ( id ) ) others . add ( timeline ) ;
3964+ return others ;
3965+ } ;
3966+ const drivenBy = ( animation : SceneAnimation , ids : string [ ] ) : SceneAnimation [ ] => {
3967+ const others = ownedElsewhere ( ids ) ;
39593968 const tweens = animation . getChildren ? animation . getChildren ( true , true , false ) : [ animation ] ;
39603969 return tweens . flatMap ( ( tween ) =>
39613970 ( tween . targets ?.( ) ?? [ ] ) . filter (
@@ -4018,7 +4027,8 @@ export function initSandboxRuntimeModular(): void {
40184027 // The gate lets a scene's script wait on fonts only, so their settling ends it.
40194028 await waitForFonts ( ) ;
40204029 await new Promise ( ( resolve ) => window . setTimeout ( resolve , 0 ) ) ;
4021- const known = new Set < unknown > ( Object . values ( recorded ) . flat ( ) ) ;
4030+ // The runtime rebuilds its root while the scene settles; that root, and other scenes' records, are not its.
4031+ const known = new Set < unknown > ( [ ...Object . values ( recorded ) . flat ( ) , ...ownedElsewhere ( [ id ] ) ] ) ;
40224032 const late = globalTimeline
40234033 . getChildren ( false , true , true )
40244034 . filter ( ( animation ) => ! before . has ( animation ) && ! known . has ( animation ) ) ;
0 commit comments