|
1 | 1 | <script lang="ts" context="module"> |
| 2 | + import { inView, scrollAnimator } from '$lib' |
2 | 3 | import { Button } from '@svelteness/kit-docs' |
3 | 4 | </script> |
4 | 5 |
|
|
24 | 25 | '-6pLFvW5_Dk', // Camera Animation Test |
25 | 26 | 'sC3FqzpDrpQ', // Diamond Golem |
26 | 27 | 'fs0NUGmsa10', // Butter Dog |
27 | | - '4VlwyI0EHo4' // Funny Mobile Game |
| 28 | + '4VlwyI0EHo4', // Funny Mobile Game |
28 | 29 | ] |
29 | 30 |
|
30 | 31 | async function getYoutubeVideoTitle(id: string) { |
|
50 | 51 | {:catch error} |
51 | 52 | <!-- --> |
52 | 53 | {/await} |
53 | | - <!-- {#key $index} |
54 | | - {/key} --> |
55 | 54 | <div class="grid"> |
56 | | - {#each VIDEOS as id} |
| 55 | + {#each VIDEOS as id, index} |
57 | 56 | <!-- svelte-ignore a11y-click-events-have-key-events --> |
58 | 57 | <!-- svelte-ignore a11y-no-static-element-interactions --> |
59 | 58 | <div |
|
67 | 66 | class="thumbnail-image" |
68 | 67 | style={`background-image: url(https://img.youtube.com/vi/${id}/0.jpg);`} |
69 | 68 | ></div> |
| 69 | + <div |
| 70 | + use:inView={{ top: 100 }} |
| 71 | + on:enter={e => { |
| 72 | + if ( |
| 73 | + e.target.parentElement?.parentElement?.parentElement?.classList.contains( |
| 74 | + 'transition-in' |
| 75 | + ) |
| 76 | + ) |
| 77 | + return |
| 78 | + e.target.parentElement.parentElement.parentElement.classList.add( |
| 79 | + 'transition-in' |
| 80 | + ) |
| 81 | + }} |
| 82 | + ></div> |
| 83 | + |
70 | 84 | {#await getYoutubeVideoTitle(id)} |
71 | 85 | <p class="loading">Loading Title...</p> |
72 | 86 | {:then title} |
|
102 | 116 | display: flex; |
103 | 117 | flex-direction: column; |
104 | 118 | align-items: center; |
| 119 | + transition: |
| 120 | + transform 0.2s ease 0s, |
| 121 | + opacity 0.2s ease 0s; |
| 122 | + transform: translateY(16px) scale(0.9); |
| 123 | + opacity: 0; |
| 124 | + } |
| 125 | + .thumbnail-container:global(.transition-in) { |
| 126 | + transform: translateY(0) scale(1); |
| 127 | + opacity: 1; |
105 | 128 | } |
106 | 129 | .thumbnail-container :global(button span) { |
107 | 130 | display: flex; |
|
0 commit comments