@@ -199,6 +199,100 @@ describe("runtime sub-composition placement", () => {
199199 expect ( window . __player ?. getDuration ( ) ) . toBe ( 9 ) ;
200200 } ) ;
201201
202+ it ( "rests a scene's longer animation at its clip's end, where the clip hides" , ( ) => {
203+ document . body . innerHTML =
204+ `<div data-composition-id="main" data-root="true" data-duration="10">` +
205+ `<div id="host" class="clip" data-composition-id="scene" data-start="1" data-duration="2">` +
206+ `<div id="s"></div></div></div>` ;
207+ let renders = 0 ;
208+ const scene = gsap
209+ . timeline ( { paused : true } )
210+ . to ( "#s" , { x : 100 , duration : 8 , ease : "none" , onUpdate : ( ) => renders ++ } , 0 ) ;
211+ const root = gsap . timeline ( { paused : true } ) . to ( { } , { duration : 10 } , 0 ) ;
212+ window . __timelines = { main : root , scene } as unknown as Record < string , RuntimeTimelineLike > ;
213+ initSandboxRuntimeModular ( ) ;
214+
215+ window . __player ?. seek ( 2 ) ;
216+ expect ( shownX ( ) ) . toBe ( 12.5 ) ;
217+ window . __player ?. seek ( 5 ) ;
218+ expect ( shownX ( ) ) . toBe ( 25 ) ;
219+ expect ( getComputedStyle ( document . getElementById ( "host" ) ! ) . visibility ) . toBe ( "hidden" ) ;
220+ renders = 0 ;
221+ window . __player ?. seek ( 6 ) ;
222+ expect ( renders ) . toBe ( 0 ) ;
223+ } ) ;
224+
225+ it ( "keeps a slow scene with no clip window animating while it shows" , ( ) => {
226+ document . body . innerHTML =
227+ `<div data-composition-id="main" data-root="true" data-duration="20">` +
228+ `<div id="host" data-composition-id="scene" data-playback-rate="0.5">` +
229+ `<div id="s"></div></div></div>` ;
230+ const scene = gsap
231+ . timeline ( { paused : true } )
232+ . to ( "#s" , { x : 100 , duration : 8 , ease : "none" } , 0 ) ;
233+ const root = gsap . timeline ( { paused : true } ) . to ( { } , { duration : 20 } , 0 ) ;
234+ window . __timelines = { main : root , scene } as unknown as Record < string , RuntimeTimelineLike > ;
235+ initSandboxRuntimeModular ( ) ;
236+
237+ window . __player ?. seek ( 6 ) ;
238+ window . __player ?. seek ( 12 ) ;
239+ expect ( shownX ( ) ) . toBe ( 75 ) ;
240+ } ) ;
241+
242+ it ( "keeps a slow scene Studio stamped animating past its stamp, once the root has grown" , ( ) => {
243+ const parent = window . parent ;
244+ Object . defineProperty ( window , "parent" , { configurable : true , value : { } } ) ;
245+ try {
246+ // What Studio leaves after a root extension: the host's discovery stamp still ends at 10 s.
247+ document . body . innerHTML =
248+ `<div data-composition-id="main" data-root="true" data-duration="20">` +
249+ `<div id="host" style="position: absolute" data-composition-id="scene" data-playback-rate="0.5"` +
250+ ` data-start="0" data-duration="10" data-hf-autostamped="1"><div id="s"></div></div></div>` ;
251+ const scene = gsap
252+ . timeline ( { paused : true } )
253+ . to ( "#s" , { x : 100 , duration : 8 , ease : "none" } , 0 ) ;
254+ const root = gsap . timeline ( { paused : true } ) . to ( { } , { duration : 20 } , 0 ) ;
255+ window . __timelines = { main : root , scene } as unknown as Record < string , RuntimeTimelineLike > ;
256+ initSandboxRuntimeModular ( ) ;
257+
258+ window . __player ?. seek ( 6 ) ;
259+ window . __player ?. seek ( 12 ) ;
260+ expect ( shownX ( ) ) . toBe ( 75 ) ;
261+ expect ( getComputedStyle ( document . getElementById ( "host" ) ! ) . visibility ) . not . toBe ( "hidden" ) ;
262+ } finally {
263+ Object . defineProperty ( window , "parent" , { configurable : true , value : parent } ) ;
264+ }
265+ } ) ;
266+
267+ it ( "renders a scene past its clip's end where root propagation leaves it, replaying no callbacks" , ( ) => {
268+ document . body . innerHTML =
269+ `<div data-composition-id="main" data-root="true" data-duration="10">` +
270+ `<div id="host" class="clip" data-composition-id="scene" data-start="1" data-duration="2">` +
271+ `<div id="s"></div></div></div>` ;
272+ let callbacks = 0 ;
273+ const scene = gsap . timeline ( { paused : true } ) . to (
274+ "#s" ,
275+ {
276+ x : 100 ,
277+ duration : 8 ,
278+ ease : "none" ,
279+ onUpdate : ( ) => callbacks ++ ,
280+ onComplete : ( ) => callbacks ++ ,
281+ } ,
282+ 0 ,
283+ ) ;
284+ const root = gsap . timeline ( { paused : true } ) . to ( { } , { duration : 10 } , 0 ) ;
285+ window . __timelines = { main : root , scene } as unknown as Record < string , RuntimeTimelineLike > ;
286+ initSandboxRuntimeModular ( ) ;
287+
288+ window . __player ?. renderSeek ( 9.1 ) ;
289+ expect ( shownX ( ) ) . toBe ( 100 ) ;
290+ callbacks = 0 ;
291+ window . __player ?. renderSeek ( 9.2 ) ;
292+ window . __player ?. renderSeek ( 9.3 , { suppressEvents : true } ) ;
293+ expect ( callbacks ) . toBe ( 0 ) ;
294+ } ) ;
295+
202296 it ( "keeps the scene in one root after a tween first renders, when the root's own timeline is empty" , async ( ) => {
203297 const runFrames = stubFrames ( ) ;
204298 document . body . innerHTML =
0 commit comments