Index: Added basic animation for "Photographie"
This commit is contained in:
parent
3a67ee23b8
commit
9c27bf143a
2 changed files with 30 additions and 30 deletions
|
@ -15,7 +15,6 @@
|
||||||
let cursorX;
|
let cursorX;
|
||||||
let cursorY;
|
let cursorY;
|
||||||
|
|
||||||
let navbar_title;
|
|
||||||
let navbar_category;
|
let navbar_category;
|
||||||
|
|
||||||
function isActive(str, url) {
|
function isActive(str, url) {
|
||||||
|
@ -73,15 +72,6 @@
|
||||||
class={scrollY < SCROLL
|
class={scrollY < SCROLL
|
||||||
? "disabled"
|
? "disabled"
|
||||||
: "navbar-height flex-row container"}
|
: "navbar-height flex-row container"}
|
||||||
on:mousemove={(event) => {
|
|
||||||
update_gradient(event, navbar_title);
|
|
||||||
}}
|
|
||||||
on:mouseenter={() => {
|
|
||||||
animateForeground(true, navbar_title);
|
|
||||||
}}
|
|
||||||
on:mouseleave={() => {
|
|
||||||
animateForeground(false, navbar_title);
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div class="navbar-title navbar-content">
|
<div class="navbar-title navbar-content">
|
||||||
<h1 class="title">Etheryo</h1>
|
<h1 class="title">Etheryo</h1>
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
import Git from "$lib/components/git.svelte";
|
import Git from "$lib/components/git.svelte";
|
||||||
import HoverCard from "$lib/components/hover-card.svelte";
|
import HoverCard from "$lib/components/hover-card.svelte";
|
||||||
|
|
||||||
|
import anime from "animejs";
|
||||||
import topics from "$lib/ts/topic.ts";
|
import topics from "$lib/ts/topic.ts";
|
||||||
import { filterPhotos } from "$lib/ts/photo.ts";
|
import { filterPhotos } from "$lib/ts/photo.ts";
|
||||||
|
|
||||||
|
@ -16,23 +17,36 @@
|
||||||
|
|
||||||
let photoList = filterPhotos(hubjson.photos);
|
let photoList = filterPhotos(hubjson.photos);
|
||||||
$: index = 0;
|
$: index = 0;
|
||||||
|
let photoDiv;
|
||||||
|
let tempPhotoDiv;
|
||||||
|
|
||||||
function swipeCanva(event, canva) {
|
function updateIndex(advance) {
|
||||||
const id = index;
|
if (advance && index < photoList.length - 1) {
|
||||||
|
index++;
|
||||||
|
} else if (!advance && index >= 1) {
|
||||||
|
index--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function swipeCanva(advance) {
|
||||||
const width = window.innerWidth / 2;
|
const width = window.innerWidth / 2;
|
||||||
const animTranslate = active > id ? [width, -width] : [-width, width];
|
const animTranslate = advance ? [-width, width] : [width, -width];
|
||||||
|
|
||||||
|
// Checking if we can play the animation
|
||||||
|
if (!((advance && index < photoList.length - 1) || (!advance && index >= 1)))
|
||||||
|
return;
|
||||||
|
|
||||||
anime({
|
anime({
|
||||||
targets: pageDiv,
|
targets: photoDiv,
|
||||||
translateX: animTranslate[0],
|
translateX: animTranslate[0],
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
duration: 300,
|
duration: 300,
|
||||||
easing: "easeInQuad",
|
easing: "easeInQuad",
|
||||||
complete: function () {
|
complete: function () {
|
||||||
active = id;
|
updateIndex(advance);
|
||||||
pageDiv.style.transform = `translateX(${animTranslate[1]}px)`;
|
photoDiv.style.transform = `translateX(${animTranslate[1]}px)`;
|
||||||
anime({
|
anime({
|
||||||
targets: pageDiv,
|
targets: photoDiv,
|
||||||
translateX: 0,
|
translateX: 0,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
duration: 300,
|
duration: 300,
|
||||||
|
@ -94,7 +108,7 @@
|
||||||
<h1>{hubjson.photo.title}</h1>
|
<h1>{hubjson.photo.title}</h1>
|
||||||
<p>{hubjson.photo.description}</p>
|
<p>{hubjson.photo.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex w-100 justify-center">
|
<div class="flex w-100 justify-center" bind:this={photoDiv}>
|
||||||
{#each photoList[index] as photo}
|
{#each photoList[index] as photo}
|
||||||
<HoverCard
|
<HoverCard
|
||||||
picture={photo.urlcompressed}
|
picture={photo.urlcompressed}
|
||||||
|
@ -105,16 +119,12 @@
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
<button
|
<!-- Just to load the next picture -->
|
||||||
on:click={() => {
|
<div class="flex w-100 justify-center disabled" bind:this={tempPhotoDiv}>
|
||||||
if (index >= 1) index--;
|
{#each photoList[index + 1] as photo}
|
||||||
|
<img alt="nothing" src={photo.urlcompressed} />
|
||||||
|
{/each}
|
||||||
}}><</button
|
</div>
|
||||||
>
|
<button on:click={() => swipeCanva(false)}><</button>
|
||||||
<button
|
<button on:click={() => swipeCanva(true)}>></button>
|
||||||
on:click={() => {
|
|
||||||
if (index < photoList.length - 1) index++;
|
|
||||||
}}>></button
|
|
||||||
>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue