-
-
Notifications
You must be signed in to change notification settings - Fork 282
Expand file tree
/
Copy path_Masonry.svelte
More file actions
32 lines (30 loc) · 807 Bytes
/
_Masonry.svelte
File metadata and controls
32 lines (30 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<ImageList class="my-image-list-masonry" masonry>
{#each Array(15) as _unused, i}
<Item>
<Image
src="https://placehold.co/190x{getUnevenImageSize(
i,
107,
200,
Math.abs,
)}?text=190x{getUnevenImageSize(i, 107, 200, Math.abs)}"
alt="Image {i + 1}"
/>
<Supporting>
<Label>Image {i + 1}</Label>
</Supporting>
</Item>
{/each}
</ImageList>
<script lang="ts">
import ImageList, { Item, Image, Supporting, Label } from '@smui/image-list';
function getUnevenImageSize(
counter: number,
base: number,
variance: number,
preAdd = (num: number) => num,
) {
const mid = (counter % 2 ? Math.cos : Math.sin)(counter) * variance;
return base + Math.floor(preAdd(mid));
}
</script>