@@ -211,7 +211,7 @@ export interface CrossfadeParams {
211
211
easing ?: EasingFunction ;
212
212
}
213
213
214
- type ClientRectMap = Map < any , { rect : ClientRect } > ;
214
+ type ClientRectMap = Map < any , Element > ;
215
215
216
216
export function crossfade ( { fallback, ...defaults } : CrossfadeParams & {
217
217
fallback ?: ( node : Element , params : CrossfadeParams , intro : boolean ) => TransitionConfig ;
@@ -232,13 +232,14 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
232
232
const to_receive : ClientRectMap = new Map ( ) ;
233
233
const to_send : ClientRectMap = new Map ( ) ;
234
234
235
- function crossfade ( from : ClientRect , node : Element , params : CrossfadeParams ) : TransitionConfig {
235
+ function crossfade ( from_node : Element , node : Element , params : CrossfadeParams ) : TransitionConfig {
236
236
const {
237
237
delay = 0 ,
238
238
duration = d => Math . sqrt ( d ) * 30 ,
239
239
easing = cubicOut
240
240
} = assign ( assign ( { } , defaults ) , params ) ;
241
241
242
+ const from = from_node . getBoundingClientRect ( ) ;
242
243
const to = node . getBoundingClientRect ( ) ;
243
244
const dx = from . left - to . left ;
244
245
const dy = from . top - to . top ;
@@ -264,16 +265,14 @@ export function crossfade({ fallback, ...defaults }: CrossfadeParams & {
264
265
265
266
function transition ( items : ClientRectMap , counterparts : ClientRectMap , intro : boolean ) {
266
267
return ( node : Element , params : CrossfadeParams & { key : any } ) => {
267
- items . set ( params . key , {
268
- rect : node . getBoundingClientRect ( )
269
- } ) ;
268
+ items . set ( params . key , node ) ;
270
269
271
270
return ( ) => {
272
271
if ( counterparts . has ( params . key ) ) {
273
- const { rect } = counterparts . get ( params . key ) ;
272
+ const other_node = counterparts . get ( params . key ) ;
274
273
counterparts . delete ( params . key ) ;
275
274
276
- return crossfade ( rect , node , params ) ;
275
+ return crossfade ( other_node , node , params ) ;
277
276
}
278
277
279
278
// if the node is disappearing altogether
0 commit comments