Rework Location page photos ratio and hover
Defines if the photo is under 3/2 by calculating ratio from width and height
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
export let photoAlt: string
|
export let photoAlt: string
|
||||||
export let title: string
|
export let title: string
|
||||||
export let index: string
|
export let index: string
|
||||||
export let orientation: string = undefined
|
export let ratio: number
|
||||||
export let date: string = undefined
|
export let date: string = undefined
|
||||||
export let city: string = undefined
|
export let city: string = undefined
|
||||||
</script>
|
</script>
|
||||||
@@ -31,10 +31,11 @@
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<figure class="house__photo"
|
<div class="house__photo"
|
||||||
class:not-landscape={orientation && orientation !== 'landscape'}
|
class:not-landscape={ratio < 1.475}
|
||||||
>
|
>
|
||||||
<a href={url} sveltekit:noscroll tabindex="0">
|
<a href={url} sveltekit:noscroll tabindex="0">
|
||||||
|
<figure class="house__image shadow-photo">
|
||||||
<Image
|
<Image
|
||||||
id={photoId}
|
id={photoId}
|
||||||
sizeKey="photo-list"
|
sizeKey="photo-list"
|
||||||
@@ -45,11 +46,12 @@
|
|||||||
}}
|
}}
|
||||||
ratio={1.5}
|
ratio={1.5}
|
||||||
alt={photoAlt}
|
alt={photoAlt}
|
||||||
class="photo shadow-photo"
|
class="photo"
|
||||||
/>
|
/>
|
||||||
|
</figure>
|
||||||
<span class="house__index title-index">
|
<span class="house__index title-index">
|
||||||
{index}
|
{index}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</figure>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -54,7 +54,6 @@ export async function get({ params }: RequestEvent): Promise<RequestHandlerOutpu
|
|||||||
id
|
id
|
||||||
title
|
title
|
||||||
}
|
}
|
||||||
orientation
|
|
||||||
city
|
city
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -264,14 +264,14 @@
|
|||||||
|
|
||||||
{#if photos.length}
|
{#if photos.length}
|
||||||
<section class="location-page__houses grid" bind:this={photosListEl}>
|
<section class="location-page__houses grid" bind:this={photosListEl}>
|
||||||
{#each photos as { title, image: { id, title: alt }, orientation, slug, city, date_taken }, index}
|
{#each photos as { title, image: { id, title: alt, width, height }, slug, city, date_taken }, index}
|
||||||
<House
|
<House
|
||||||
{title}
|
{title}
|
||||||
photoId={id}
|
photoId={id}
|
||||||
photoAlt={alt}
|
photoAlt={alt}
|
||||||
{orientation}
|
|
||||||
url="/{params.country}/{params.location}/{slug}"
|
url="/{params.country}/{params.location}/{slug}"
|
||||||
{city}
|
{city}
|
||||||
|
ratio={width / height}
|
||||||
date={date_taken}
|
date={date_taken}
|
||||||
index={(totalPhotos - index < 10) ? '0' : ''}{totalPhotos - index}
|
index={(totalPhotos - index < 10) ? '0' : ''}{totalPhotos - index}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ export const photoFields = `
|
|||||||
image {
|
image {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
|
width, height
|
||||||
}
|
}
|
||||||
orientation
|
|
||||||
date_taken
|
date_taken
|
||||||
date_created
|
date_created
|
||||||
`
|
`
|
||||||
|
|||||||
@@ -77,14 +77,30 @@
|
|||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 2s var(--ease-quart);
|
transition: opacity 2s var(--ease-quart);
|
||||||
|
|
||||||
picture {
|
figure {
|
||||||
position: relative;
|
position: relative;
|
||||||
z-index: 3;
|
z-index: 5;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
height: 100%;
|
||||||
|
aspect-ratio: 3 / 2;
|
||||||
|
overflow: hidden;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
|
|
||||||
@include bp (sm) {
|
@include bp (sm) {
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@supports not (aspect-ratio: auto) {
|
||||||
|
position: relative;
|
||||||
|
overflow: hidden;
|
||||||
|
padding-top: 66.66%;
|
||||||
|
height: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
picture {
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
img {
|
img {
|
||||||
display: block;
|
display: block;
|
||||||
@@ -94,27 +110,6 @@
|
|||||||
transform: scale3d(1.125, 1.125, 1.125);
|
transform: scale3d(1.125, 1.125, 1.125);
|
||||||
transition: transform 2s var(--ease-quart), opacity 1.2s var(--ease-quart);
|
transition: transform 2s var(--ease-quart), opacity 1.2s var(--ease-quart);
|
||||||
will-change: transform;
|
will-change: transform;
|
||||||
}
|
|
||||||
|
|
||||||
// Variant: Not landscape
|
|
||||||
&.not-landscape {
|
|
||||||
aspect-ratio: 3 / 2;
|
|
||||||
|
|
||||||
@supports not (aspect-ratio: auto) {
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
padding-top: 66.66%;
|
|
||||||
height: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
picture {
|
|
||||||
height: 100%;
|
|
||||||
background: $color-cream;
|
|
||||||
}
|
|
||||||
img {
|
|
||||||
height: 100%;
|
|
||||||
width: 100%;
|
|
||||||
object-fit: contain;
|
|
||||||
|
|
||||||
@supports not (aspect-ratio: auto) {
|
@supports not (aspect-ratio: auto) {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -126,13 +121,19 @@
|
|||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Variant: Not landscape
|
||||||
|
&.not-landscape {
|
||||||
|
figure {
|
||||||
|
background: $color-cream;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scale down image on hover
|
// Scale down image on hover
|
||||||
@media (hover: hover) {
|
@media (hover: hover) {
|
||||||
a:hover {
|
a:hover {
|
||||||
img {
|
img {
|
||||||
opacity: 0.8;
|
opacity: 0.7;
|
||||||
transform: scale3d(1.03, 1.03, 1.03) !important;
|
transform: scale3d(1.03, 1.03, 1.03) !important;
|
||||||
transition-duration: 1.2s;
|
transition-duration: 1.2s;
|
||||||
}
|
}
|
||||||
@@ -140,26 +141,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Visible state
|
|
||||||
&.is-visible {
|
|
||||||
.house__info {
|
|
||||||
h2 {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translate3d(0,0,0);
|
|
||||||
}
|
|
||||||
.info {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.house__photo {
|
|
||||||
opacity: 1;
|
|
||||||
|
|
||||||
img {
|
|
||||||
transform: scale3d(1,1,1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Photo number
|
// Photo number
|
||||||
&__index {
|
&__index {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -206,4 +187,24 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visible state
|
||||||
|
&.is-visible {
|
||||||
|
.house__info {
|
||||||
|
h2 {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translate3d(0,0,0);
|
||||||
|
}
|
||||||
|
.info {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.house__photo {
|
||||||
|
opacity: 1;
|
||||||
|
|
||||||
|
img {
|
||||||
|
transform: scale3d(1,1,1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user