|
5 | 5 | export let avatarUrl: string = '';
|
6 | 6 | export let altText: string = '';
|
7 | 7 | export let channelId: string = '';
|
| 8 | + export let listId: string = ''; |
8 | 9 |
|
9 | 10 | let currentUrl = '';
|
10 | 11 | let showFallback = false;
|
|
25 | 26 |
|
26 | 27 | {#if !showFallback}
|
27 | 28 | <img
|
28 |
| - use:transition={`avatar-${channelId}`} |
| 29 | + use:transition={{ |
| 30 | + name: `avatar-${channelId}`, |
| 31 | + shouldApply({ navigation }) { |
| 32 | + // here we are navigating from main page to detail page |
| 33 | + if (navigation.to?.params?.id != null) { |
| 34 | + // we should apply if the id we are navigating to |
| 35 | + // has the listId of this avatar |
| 36 | + return navigation.to.params.id === listId; |
| 37 | + } |
| 38 | + // here we are navigating back from the detail to the home, we should apply |
| 39 | + // only if we are coming from the page with the same id as listId |
| 40 | + return navigation.from?.params?.id === listId; |
| 41 | + }, |
| 42 | + applyImmediately({ navigation }) { |
| 43 | + // here we are navigating from main page to detail page |
| 44 | + if (navigation.to?.params?.id != null) { |
| 45 | + // we should apply immediately if the id we are navigating to |
| 46 | + // has the listId of this avatar |
| 47 | + return navigation.to.params.id === listId; |
| 48 | + } |
| 49 | + // here we are navigating back from the detail to the home, we should apply |
| 50 | + // immediately only if we are coming from the page with the same id as listId |
| 51 | + return navigation.from?.params?.id === listId; |
| 52 | + }, |
| 53 | + }} |
29 | 54 | class="mr-1 inline-block h-14 w-14 rounded-full"
|
30 | 55 | referrerpolicy="no-referrer"
|
31 | 56 | src={currentUrl}
|
|
0 commit comments