Commit 82a2ba2
Share the same Animated.Value amongst transitions that happen in the same commit
Right now, updating state which affects transitioning properties accross
multiple components results in each component creating its own
Animated.Value and starting the animation in an effect.
This results in animations that are not in sync as they should be.
In this PR, transitions with the same delay, duration, timing function share
the same Animated.Value as long as they're part of the same commit.
useLayoutEffect is used to either create the Animated.Value or find an
existing suitable one to use.
Since all layout effects run before effects, we can assume that by the
time any component's effect runs, all Animated.Values have been created
or shared.
One of the component's effects will then kick off the animation and
empty the shared animation config map so that future commits don't
reuse any of the Animated.Values that were created. The other
component's effects will be no-ops.
Finally, reference counting is used to ensure only the last component
that unmounts would stop the animation if it was still running since
now they are shared it would be disruptive to stop the animation
unless the component was the last one relying on it1 parent e8cdaa5 commit 82a2ba2
1 file changed
Lines changed: 80 additions & 28 deletions
Lines changed: 80 additions & 28 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
32 | 39 | | |
33 | 40 | | |
34 | 41 | | |
| |||
260 | 267 | | |
261 | 268 | | |
262 | 269 | | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
263 | 317 | | |
264 | 318 | | |
265 | 319 | | |
| |||
292 | 346 | | |
293 | 347 | | |
294 | 348 | | |
295 | | - | |
| 349 | + | |
296 | 350 | | |
297 | 351 | | |
298 | 352 | | |
| |||
321 | 375 | | |
322 | 376 | | |
323 | 377 | | |
324 | | - | |
| 378 | + | |
325 | 379 | | |
326 | | - | |
327 | | - | |
328 | | - | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
329 | 389 | | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
338 | | - | |
339 | | - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
340 | 394 | | |
341 | | - | |
342 | | - | |
343 | | - | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
344 | 402 | | |
345 | | - | |
| 403 | + | |
346 | 404 | | |
347 | 405 | | |
348 | 406 | | |
| |||
354 | 412 | | |
355 | 413 | | |
356 | 414 | | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | 415 | | |
366 | 416 | | |
367 | 417 | | |
368 | 418 | | |
| 419 | + | |
| 420 | + | |
369 | 421 | | |
370 | 422 | | |
371 | 423 | | |
| |||
0 commit comments