MORE FANCY (MOUSE BITES)

This commit is contained in:
cirroskais 2024-04-20 21:54:02 -04:00
parent 0343eed4be
commit 315b7576b4
No known key found for this signature in database
GPG key ID: 5FC73EBF2678E33D
2 changed files with 13 additions and 3 deletions

View file

@ -12,7 +12,7 @@
<div class="my-auto w-5 h-5 font-bold">
<Eye></Eye>
</div>
<p>This page has been viewed <span class="font-bold">100</span> times.</p>
<p>This page has been viewed <span class="font-bold">x</span> times.</p>
</div>
</div>
<div class="flex flex-col my-auto ml-auto text-sm text-neutral-500">

View file

@ -1,5 +1,6 @@
<script>
import { onMount } from 'svelte';
import { fade } from 'svelte/transition';
/** @type {string} src */
export let src;
@ -10,6 +11,8 @@
/** @type {HTMLImageElement} e */
let e;
let loaded = false;
// https://github.com/nbitzz/newnewwebsite/blob/a751e690a9993923aabd1984d9645c502f148c69/src/components/buttons/Buttons.astro#L74-L95
onMount(() => {
/** @param {MouseEvent} ev */
@ -21,7 +24,7 @@
` rotate3d(${yP.toFixed(2)}, ${xP.toFixed(2)},0,20deg)` +
` translate(${3 * xP}px,${-5 * yP}px)`;
e.style.boxShadow = 'gray 0px 0px 10px';
e.style.boxShadow = `${(-3 * xP).toFixed(2)}px ${(5 * yP).toFixed(2)}px 3px #c4bef3`;
};
e.addEventListener('mouseover', startEffect);
@ -30,11 +33,16 @@
e.style.transform = '';
e.style.boxShadow = '';
});
const preload = new Image();
preload.src = src;
preload.onload = () => (loaded = true);
});
</script>
<a class="hover:shadow-2xl" {href} target="_blank">
<img class="imgbutton" {src} alt="Button" bind:this={e} />
<img in:fade class="imgbutton {!loaded && 'hidden'}" {src} alt="Button" bind:this={e} />
<div class="animate-pulse imgbutton bg-neutral-600/50 rounded-sm {loaded && 'hidden'}"></div>
</a>
<style lang="postcss">
@ -42,5 +50,7 @@
transition-property: transform;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 70ms;
height: 31px;
width: 88px;
}
</style>