feat: add clicked effect on Photo viewer nav buttons + fade on name

This commit is contained in:
2024-08-03 14:42:53 +02:00
parent 0c8076097e
commit 8186e07335
2 changed files with 471 additions and 450 deletions

View File

@@ -224,14 +224,14 @@
*/ */
const animation = timeline([ const animation = timeline([
// First photo // First photo
['.photo-page__picture.is-1', { ['.picture.is-1', {
y: [24, 0], y: [24, 0],
opacity: [0, 1], opacity: [0, 1],
}, { }, {
duration: 0.9, duration: 0.9,
}], }],
// Other photos // Other photos
['.photo-page__picture:not(.is-1)', { ['.picture:not(.is-1)', {
x: ['-15%', '0%'], x: ['-15%', '0%'],
opacity: [0, 1], opacity: [0, 1],
}, { }, {
@@ -241,13 +241,13 @@
}], }],
// Prev/Next buttons // Prev/Next buttons
['.photo-page__controls .prev', { ['.controls .prev button', {
x: [-16, 0], x: [-16, 0],
opacity: [0, 1], opacity: [0, 1],
}, { }, {
at: 0.45, at: 0.45,
}], }],
['.photo-page__controls .next', { ['.controls .next button', {
x: [16, 0], x: [16, 0],
opacity: [0, 1], opacity: [0, 1],
}, { }, {
@@ -255,7 +255,7 @@
}], }],
// Infos // Infos
['.photo-page__info > *', { ['.info > *', {
y: [24, 0], y: [24, 0],
opacity: [0, 1], opacity: [0, 1],
}, { }, {
@@ -264,7 +264,7 @@
}], }],
// Index // Index
['.photo-page__index', { ['.index', {
opacity: [0, 1], opacity: [0, 1],
}, { }, {
at: 0.6, at: 0.6,
@@ -272,7 +272,7 @@
duration: 0.9, duration: 0.9,
}], }],
// Fly each number // Fly each number
['.photo-page__index .char', { ['.index .char', {
y: ['300%', 0], y: ['300%', 0],
}, { }, {
at: 1.1, at: 1.1,
@@ -306,7 +306,7 @@
<main class="photo-page"> <main class="photo-page">
<div class="container grid"> <div class="container grid">
<p class="photo-page__notice text-label">Tap for fullscreen</p> <p class="notice text-label">Tap for fullscreen</p>
<ButtonCircle <ButtonCircle
tag="a" tag="a"
@@ -320,15 +320,15 @@
</svg> </svg>
</ButtonCircle> </ButtonCircle>
<div class="photo-page__carousel"> <div class="carousel">
<div <div
class="photo-page__images" class="images"
use:swipe use:swipe
onswipe={handleSwipe} onswipe={handleSwipe}
ontap={toggleFullscreen} ontap={toggleFullscreen}
> >
{#each visiblePhotos as { id, image, title }, index (id)} {#each visiblePhotos as { id, image, title }, index (id)}
<div class="photo-page__picture is-{currentIndex === 0 ? index + 1 : index}"> <div class="picture is-{currentIndex === 0 ? index + 1 : index}">
<Image <Image
class="photo {image.width / image.height < 1.475 ? 'not-landscape' : ''}" class="photo {image.width / image.height < 1.475 ? 'not-landscape' : ''}"
id={image.id} id={image.id}
@@ -344,24 +344,32 @@
</div> </div>
{/each} {/each}
<div class="photo-page__controls"> <nav class="controls">
<ButtonCircle class="prev shadow-box-dark" label="Previous" disabled={!canGoNext} clone={true} onclick={goToPrevious}> <div class="prev" class:is-disabled={!canGoNext}>
<ButtonCircle class="shadow-box-dark" label="Previous" disabled={!canGoNext} clone={true} onclick={goToPrevious}>
<IconArrow color="pink" flip={true} /> <IconArrow color="pink" flip={true} />
</ButtonCircle> </ButtonCircle>
<ButtonCircle class="next shadow-box-dark" label="Next" disabled={!canGoPrev} clone={true} onclick={goToNext}> </div>
<div class="next" class:is-disabled={!canGoPrev}>
<ButtonCircle class="shadow-box-dark" label="Next" disabled={!canGoPrev} clone={true} onclick={goToNext}>
<IconArrow color="pink" /> <IconArrow color="pink" />
</ButtonCircle> </ButtonCircle>
</div> </div>
</nav>
<div class="photo-page__index title-index">
<div class="index title-index"> <div class="index title-index">
<SplitText text={padZero(currentPhotoIndex)} mode="chars" /> <SplitText text={padZero(currentPhotoIndex)} mode="chars" />
</div> </div>
</div> </div>
<div class="photo-page__info"> <div class="info">
<h1 class="title-medium">{currentPhoto.title}</h1> <div class="name">
{#key currentPhoto}
<h1 class="title-medium" in:fade={{ duration: 250, delay: 250 }} out:fade={{ duration: 250 }}>
{currentPhoto.title}
</h1>
{/key}
</div>
<div class="detail text-info"> <div class="detail text-info">
<a href="/{data.location.country.slug}/{data.location.slug}" data-sveltekit-noscroll> <a href="/{data.location.country.slug}/{data.location.slug}" data-sveltekit-noscroll>
@@ -386,7 +394,7 @@
{#if isFullscreen} {#if isFullscreen}
<div <div
bind:this={fullscreenEl} bind:this={fullscreenEl}
class="photo-page__fullscreen" class="fullscreen"
onclick={toggleFullscreen} onclick={toggleFullscreen}
in:fade={{ easing: quartOut, duration: 1000 }} in:fade={{ easing: quartOut, duration: 1000 }}
out:fade={{ easing: quartOut, duration: 1000, delay: 300 }} out:fade={{ easing: quartOut, duration: 1000, delay: 300 }}

View File

@@ -6,6 +6,38 @@
align-items: center; align-items: center;
overflow: hidden; overflow: hidden;
// Close button
:global(.close) {
--offset: 16px;
position: fixed !important;
z-index: 2;
top: var(--offset);
right: var(--offset);
@include bp (sm) {
--offset: clamp(20px, 3vw, 40px);
}
:global(svg) {
max-width: 14px;
max-height: 14px;
@include bp (md) {
max-width: 20px;
max-height: 20px;
}
}
// Hover
&:hover {
:global(svg) {
transform: rotate3d(0, 0, 1, 90deg) !important;
transition-duration: 1.2s;
}
}
}
}
.container { .container {
position: relative; position: relative;
width: 100%; width: 100%;
@@ -17,7 +49,7 @@
} }
// Carousel // Carousel
&__carousel { .carousel {
position: absolute; position: absolute;
top: 0; top: 0;
left: 50%; left: 50%;
@@ -44,7 +76,7 @@
} }
// Images // Images
&__images { .images {
position: relative; position: relative;
width: 100%; width: 100%;
margin: auto auto 0; margin: auto auto 0;
@@ -52,7 +84,7 @@
touch-action: none; touch-action: none;
} }
&__picture { .picture {
--opacity: 1; --opacity: 1;
--scale: 0.6; --scale: 0.6;
--rotate: 0deg; --rotate: 0deg;
@@ -220,7 +252,7 @@
} }
// Infos // Infos
&__info { .info {
bottom: 0; bottom: 0;
margin-top: auto; margin-top: auto;
margin-bottom: 40px; margin-bottom: 40px;
@@ -239,7 +271,11 @@
align-items: baseline; align-items: baseline;
} }
.name {
display: grid;
}
h1 { h1 {
grid-area: 1 / -1 / 1 / -1;
color: $color-secondary; color: $color-secondary;
font-size: clamp(#{rem(18px)}, 5.5vw, #{rem(28px)}); font-size: clamp(#{rem(18px)}, 5.5vw, #{rem(28px)});
line-height: 1.1; line-height: 1.1;
@@ -290,7 +326,7 @@
} }
// Index // Index
&__index { .index {
position: absolute; position: absolute;
z-index: 1; z-index: 1;
left: 50%; left: 50%;
@@ -322,7 +358,7 @@
} }
// Controls // Controls
&__controls { .controls {
display: none; display: none;
@include bp (md) { @include bp (md) {
@@ -337,12 +373,19 @@
pointer-events: none; pointer-events: none;
} }
:global(button) { div {
transition: transform 0.3s var(--ease-quart);
pointer-events: auto; pointer-events: auto;
// State: Shrink down when clicking
&:not(.is-disabled):active {
transform: scale(0.9);
}
}
// Prev button // Prev button
&:first-child { .prev :global(button) {
& > :global(*:nth-child(2)) { :global(> *:nth-child(2)) {
transform: translate3d(100%, -50%, 0) rotate(180deg); transform: translate3d(100%, -50%, 0) rotate(180deg);
} }
@@ -357,7 +400,9 @@
} }
} }
// Hover // State: Hover
:global(button) {
// Common button styles
&:not([disabled]):hover { &:not([disabled]):hover {
background-color: $color-secondary; background-color: $color-secondary;
color: #fff; color: #fff;
@@ -370,7 +415,7 @@
} }
// Fullscreen viewer // Fullscreen viewer
&__fullscreen { .fullscreen {
position: absolute; position: absolute;
z-index: 102; z-index: 102;
top: 0; top: 0;
@@ -419,7 +464,7 @@
} }
// Notice // Notice
&__notice { .notice {
position: absolute; position: absolute;
top: 16px; top: 16px;
left: 20px; left: 20px;
@@ -430,35 +475,3 @@
display: none; display: none;
} }
} }
// Close button
:global(.close) {
--offset: 16px;
position: fixed !important;
z-index: 2;
top: var(--offset);
right: var(--offset);
@include bp (sm) {
--offset: clamp(20px, 3vw, 40px);
}
:global(svg) {
max-width: 14px;
max-height: 14px;
@include bp (md) {
max-width: 20px;
max-height: 20px;
}
}
// Hover
&:hover {
:global(svg) {
transform: rotate3d(0, 0, 1, 90deg) !important;
transition-duration: 1.2s;
}
}
}
}