@@ -313,23 +313,38 @@ export function pause_effect(effect, callback = noop) {
313
313
* Pause multiple effects simultaneously, and coordinate their
314
314
* subsequent destruction. Used in each blocks
315
315
* @param {import('#client').Effect[] } effects
316
- * @param { () => void } callback
316
+ * @returns { import('#client').TransitionManager[] }
317
317
*/
318
- export function pause_effects ( effects , callback = noop ) {
318
+ export function get_out_transitions ( effects ) {
319
319
/** @type {import('#client').TransitionManager[] } */
320
320
var transitions = [ ] ;
321
- var length = effects . length ;
322
321
323
- for ( var i = 0 ; i < length ; i ++ ) {
322
+ for ( var i = 0 ; i < effects . length ; i ++ ) {
324
323
pause_children ( effects [ i ] , transitions , true ) ;
325
324
}
326
325
327
- // TODO: would be good to avoid this closure in the case where we have no
328
- // transitions at all. It would make it far more JIT friendly in the hot cases.
326
+ return transitions ;
327
+ }
328
+
329
+ /**
330
+ * @param {import('#client').Effect[] } effects
331
+ */
332
+ export function destroy_effects ( effects ) {
333
+ for ( var i = 0 ; i < effects . length ; i ++ ) {
334
+ destroy_effect ( effects [ i ] ) ;
335
+ }
336
+ }
337
+
338
+ /**
339
+ * Pause multiple effects simultaneously, and coordinate their
340
+ * subsequent destruction. Used in each blocks
341
+ * @param {import('#client').Effect[] } effects
342
+ * @param {import('#client').TransitionManager[] } transitions
343
+ * @param {() => void } callback
344
+ */
345
+ export function pause_effects ( effects , transitions , callback = noop ) {
329
346
out ( transitions , ( ) => {
330
- for ( var i = 0 ; i < length ; i ++ ) {
331
- destroy_effect ( effects [ i ] ) ;
332
- }
347
+ destroy_effects ( effects ) ;
333
348
callback ( ) ;
334
349
} ) ;
335
350
}
@@ -370,13 +385,12 @@ function pause_children(effect, transitions, local) {
370
385
var child = effect . first ;
371
386
372
387
while ( child !== null ) {
373
- var sibling = child . next ;
374
388
var transparent = ( child . f & IS_ELSEIF ) !== 0 || ( child . f & BRANCH_EFFECT ) !== 0 ;
375
389
// TODO we don't need to call pause_children recursively with a linked list in place
376
390
// it's slightly more involved though as we have to account for `transparent` changing
377
391
// through the tree.
378
392
pause_children ( child , transitions , transparent ? local : false ) ;
379
- child = sibling ;
393
+ child = child . next ;
380
394
}
381
395
}
382
396
0 commit comments