add and remove image for smoothness

This commit is contained in:
saiminh 2023-08-23 18:24:11 +02:00
parent 64b0de7013
commit de7172f686
4 changed files with 42 additions and 17 deletions

View file

@ -7,13 +7,10 @@
<Header />
{#key data.pathname}
<div
class="content"
>
<slot />
</div>
{/key}
{#key data.pathname}
<div
class="content"
>
<slot />
</div>
{/key}

View file

@ -1,9 +1,10 @@
<script lang="ts">
import WorkCanvas from '$lib/components/WorkCanvas.svelte';
import { onMount } from 'svelte';
import { onDestroy, onMount } from 'svelte';
import { workClickHandler, initWorkPage } from './workUtils.js';
import { workbulge } from '$lib/utils/stores.js';
import { CldImage } from 'svelte-cloudinary';
import { browser } from '$app/environment';
import { fade } from 'svelte/transition';
export let data;
@ -28,13 +29,20 @@
<div class="works">
{#each data.posts as work, i}
<a href="{work.path}" class="work" on:click={ (e) => workClickHandler(e) }>
<a
data-sveltekit-preload-data
href="{work.path}"
class="work"
on:click={ (e) => workClickHandler(e) }
>
<CldImage
src={work.meta.header_bg_image}
sizes="(min-width: 768px) 20vw, 50vw"
alt={work.meta.title}
width="2100"
height="1400"
objectFit="fill"
placeholder="blur"
loading= {i < 10 ? "eager" : "lazy"}
/>
<h2>{work.meta.title}</h2>

View file

@ -122,6 +122,7 @@
sizes="100vw"
width={2100}
height={1400}
placeholder="blur"
loading="eager"
objectFit="fill"
/>
@ -143,8 +144,10 @@
<style lang="scss">
article {
width: 100vw;
min-height: 100svh;
overflow: hidden;
padding-bottom: 60px;
background-color: var(--color-bg);
}
.subnav {
position: fixed;
@ -162,10 +165,6 @@
height: auto;
aspect-ratio: var(--aspect-ratio-heroes);
clip-path: polygon(0 0, 100% 0, 100% 100%, 0% 100%);
@media screen and (min-width: 768px) {
position: fixed;
}
}
:global(.heromask img) {
z-index: 0;

View file

@ -59,7 +59,12 @@ export function workClickHandler(e:Event){
const clone = targetImg.cloneNode(true) as HTMLElement;
targetImg.parentElement?.insertBefore(clone, targetImg);
targetImg.style.position = 'fixed';
const coverclone = targetImg.cloneNode(true) as HTMLElement;
coverclone.style.zIndex = '-1';
coverclone.style.visibility = 'visible';
coverclone.style.opacity = '0';
document.body.appendChild(coverclone);
gsap.to('.work:not(.active) img', {
duration: .3,
@ -70,6 +75,16 @@ export function workClickHandler(e:Event){
gsap.set(targetImg, {
zIndex: 100,
})
gsap.to(coverclone, {
duration: .3,
top: 0,
left: 0,
opacity: 1,
width: window.innerWidth,
height: window.innerWidth / targetImgAspectRatio,
ease: 'circ.inOut',
delay: 0.3
})
gsap.to(targetImg, {
duration: .3,
top: 0,
@ -78,6 +93,12 @@ export function workClickHandler(e:Event){
height: window.innerWidth / targetImgAspectRatio,
ease: 'circ.inOut',
delay: 0.3,
onComplete: () => {
setTimeout(() => {
coverclone.remove();
}, 300);
}
})
gsap.to(bulge, {
duration: .3,