Add comments and cleanup

ご主人様
not manx 4 years ago
parent 9acf6df1af
commit 856db4599a
Signed by: C-xC-c
GPG Key ID: F52ED472284EF2F4

2
.gitignore vendored

@ -1,2 +1,2 @@
node_modules node_modules
public/out public

@ -1,9 +1,6 @@
<script> <script>
import Router from 'svelte-spa-router' import Router from 'svelte-spa-router'
import Index from './index.svelte'; import Index from './index.svelte';
const themes = [
'default'
]
const routes = { const routes = {
'/': Index '/': Index

@ -1,6 +1,7 @@
<script> <script>
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import Lightbox from './lightbox.svelte'; import Lightbox from './lightbox.svelte';
let file_list; let file_list;
let open; let open;
let thumb_list = []; let thumb_list = [];
@ -16,24 +17,27 @@
.then(resp => resp.text()) .then(resp => resp.text())
.then(data => data.split('\n')); .then(data => data.split('\n'));
// Loop backwards efficiently // Loop backwards efficiently.
for (let i = file_list.length - 2; i >= 0; i--) { for (let i = file_list.length - 2; i >= 0; i--) {
const file = file_list[i]; const file = file_list[i];
// Thumbs are only ever .jpg
thumb_list.push(file.substr(0, file.lastIndexOf('.')) + '.jpg'); thumb_list.push(file.substr(0, file.lastIndexOf('.')) + '.jpg');
} }
}); });
function open_lightbox(i) { function open_lightbox(i) {
open = null; // If `open' is already `i' updates aren't sent to lightbox.
open = null;
open = i; open = i;
} }
</script> </script>
{#if file_list} {#if file_list}
<section> <section>
{#each thumb_list as thumb, i} {#each thumb_list as thumb, i}
<img on:click={() => open_lightbox(i)} src="{url.root}{url.thumb}{thumb}" /> <img on:click={() => open_lightbox(i)} src="{url.root}{url.thumb}{thumb}" />
{/each} {/each}
</section> </section>
{/if} {/if}
<Lightbox open={open} url={url} images={file_list} /> <Lightbox open={open} url={url} images={file_list} />

@ -10,7 +10,8 @@
$: image = open !== null && open >= 0 ? set_images() : ''; $: image = open !== null && open >= 0 ? set_images() : '';
$: is_open(open); $: is_open(open);
// This needs renamed
function is_open(i) { function is_open(i) {
if (should_open && i !== null && i >= 0) { if (should_open && i !== null && i >= 0) {
class_list += ' open' class_list += ' open'
@ -85,7 +86,7 @@
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
opacity: 1; opacity: 1;
transition: opacity 1s; transition: opacity 1s; /* This is being applied when we add `slide_classes' */
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
@ -96,7 +97,6 @@
background-color: rgba(0,0,0,0.7); background-color: rgba(0,0,0,0.7);
z-index: 0; z-index: 0;
} }
</style> </style>
<svelte:window on:keydown={handle_keys} /> <svelte:window on:keydown={handle_keys} />

Loading…
Cancel
Save