Skip to content

Commit

Permalink
#17: Proper scaling factor in zoom slider (#29)
Browse files Browse the repository at this point in the history
* fixed scaling for gallery

* Resolved Smooth Zoom

* Fixed footer

* Justify start

* Clean up

---------

Co-authored-by: Kawsar Ahmed <[email protected]>
  • Loading branch information
alvinosh and prokawsar authored Apr 15, 2024
1 parent 781bb20 commit c3dc213
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/Actions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
$: hasImages = $galleryStore.images?.length
</script>

<div class="mt-10 flex flex-row justify-end gap-3">
<div class="flex flex-row justify-end gap-3">
<Button
class="flex flex-row items-center gap-2 rounded-xl bg-blue-400 px-4 py-2 text-white hover:bg-blue-600 {!hasImages
? 'hidden'
Expand Down
18 changes: 8 additions & 10 deletions src/lib/components/Footer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
let zoomLevel: number[] = [$galleryStore.zoomLevel]
</script>

<div class="mx-auto flex w-full max-w-7xl flex-row justify-end px-5 py-10">
<Slider
bind:value={zoomLevel}
onValueChange={(e) => ($galleryStore.zoomLevel = e[0])}
class="w-80"
max={130}
min={80}
step={1}
/>
</div>
<Slider
bind:value={zoomLevel}
onValueChange={(e) => ($galleryStore.zoomLevel = e[0])}
class="w-80"
max={250}
min={50}
step={5}
/>
9 changes: 5 additions & 4 deletions src/lib/components/Gallery.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
import { faBan } from '@fortawesome/free-solid-svg-icons'
$: noImage = $galleryStore.selectedTag && !$galleryStore.selectedFilteredImages.length
$: imageHeight = $galleryStore.zoomLevel + 80
</script>

<div
class="gap-3 flex-1 w-full overflow-auto
{noImage
? 'flex flex-col gap-5 items-center w-full justify-center'
: 'grid grid-cols-2 md:grid-cols-4 xl:grid-cols-6'}"
class="w-full gap-3
{noImage ? 'flex flex-col items-center justify-center gap-5' : 'grid grid-flow-row justify-start'}"
style="grid-template-columns: repeat(auto-fill, {imageHeight}px);"
>
{#if noImage}
<Fa icon={faBan} size="5x" class="text-gray-400" />
Expand Down
3 changes: 0 additions & 3 deletions src/lib/components/Image.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
let hasHover = false
let typingTmr: number | undefined = undefined
$: imageHeight = $galleryStore.zoomLevel + 80
const handleKeyUp = () => {
clearTimeout(typingTmr)
typingTmr = setTimeout(() => {
Expand All @@ -38,7 +36,6 @@
on:mouseover={() => (hasHover = true)}
on:mouseleave={() => (hasHover = false)}
class="relative flex flex-col rounded-md bg-gray-100"
style="height: {imageHeight}px;"
>
<button
on:dblclick={() => openImage()}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/TagsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
</script>

<div class="my-5 flex flex-row flex-wrap items-center gap-3">
<div class="flex flex-row flex-wrap items-center gap-3">
{#if $galleryStore.activeFilter == 'tag' && $galleryStore.tags.length}
{#each $galleryStore.tags as tag}
<button
Expand Down
4 changes: 2 additions & 2 deletions src/lib/components/ui/slider/slider.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
/>
</SliderPrimitive.Root>

<span class="w-10">
<button class="w-10">
{value}%
</span>
</button>
</div>
34 changes: 23 additions & 11 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,39 @@
<title>ARK Gallery 1.0</title>
</svelte:head>

<div class="mx-auto flex h-screen w-full flex-col justify-between rounded-md">
<div class="flex h-screen w-full flex-col justify-start">
{#if imageDropping}
<div
class="absolute top-0 left-0 w-full h-full bg-blue-300 bg-opacity-50 z-50 flex items-center justify-center"
class="absolute left-0 top-0 z-50 flex h-full w-full items-center justify-center bg-blue-300 bg-opacity-50"
>
<p class="text-2xl font-bold text-white">Drop your images here</p>
</div>
{/if}
<div class:hidden={$galleryStore.galleryView} class="mx-auto w-full max-w-7xl p-5">
<div
class:hidden={$galleryStore.galleryView}
class="mx-auto flex h-full w-full max-w-7xl flex-col justify-start p-5"
>
<Filter />
<Actions
on:upload={() => uploadFolder()}
on:deleteImage={() => askDeleteImage()}
on:deleteTag={() => askDeleteTag()}
/>
<TagsList />
<Gallery />
<div class="mt-10">
<Actions
on:upload={() => uploadFolder()}
on:deleteImage={() => askDeleteImage()}
on:deleteTag={() => askDeleteTag()}
/>
</div>
<div class="my-5">
<TagsList />
</div>
<div class="flex-1 overflow-auto p-1">
<Gallery />
</div>

<div class="flex flex-col items-end justify-center pt-4">
<Footer />
</div>
</div>
<div class:hidden={!$galleryStore.galleryView}>
<Header bind:showInfo />
<ImageEditor bind:showInfo />
</div>
<Footer />
</div>

0 comments on commit c3dc213

Please sign in to comment.