Fix Homepage collage's active photo effect while hover
- Change method and use a class on collage itself fading all photos, then highlight the one being hovered - For some reason the content inside was conflicting the mouseenter event
This commit is contained in:
@@ -21,14 +21,14 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="photo-card"
|
<div class="photo-card"
|
||||||
class:is-inactive={hovered}
|
class:is-hovered={hovered}
|
||||||
on:mouseenter={() => sendHover(true)}
|
on:mouseenter={() => sendHover(true)}
|
||||||
on:focus={() => sendHover(true)}
|
on:focus={() => sendHover(true)}
|
||||||
on:mouseout={() => sendHover(false)}
|
on:mouseout={() => sendHover(false)}
|
||||||
on:blur={() => sendHover(false)}
|
on:blur={() => sendHover(false)}
|
||||||
>
|
>
|
||||||
{#if url}
|
{#if url}
|
||||||
<a href={url}>
|
<a href={url} sveltekit:noscroll>
|
||||||
<Image
|
<Image
|
||||||
id={id}
|
id={id}
|
||||||
sizeKey="postcard"
|
sizeKey="postcard"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if photos}
|
{#if photos}
|
||||||
<div class="collage">
|
<div class="collage" class:is-hovering={hovered !== null}>
|
||||||
{#each photos as { slug, title, image, location, city }, index}
|
{#each photos as { slug, title, image, location, city }, index}
|
||||||
<PhotoCard
|
<PhotoCard
|
||||||
id={image.id}
|
id={image.id}
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
title={title}
|
title={title}
|
||||||
location={location}
|
location={location}
|
||||||
city={city}
|
city={city}
|
||||||
hovered={hovered !== null && hovered !== index}
|
hovered={hovered === index}
|
||||||
on:hover={({ detail }) => hovered = detail ? index : null}
|
on:hover={({ detail }) => hovered = detail ? index : null}
|
||||||
/>
|
/>
|
||||||
{/each}
|
{/each}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@
|
|||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
color: $color-cream;
|
color: $color-cream;
|
||||||
|
pointer-events: none;
|
||||||
font-size: clamp(#{rem(12px)}, 1.5vw, #{rem(14px)});
|
font-size: clamp(#{rem(12px)}, 1.5vw, #{rem(14px)});
|
||||||
|
|
||||||
@include bp (sm) {
|
@include bp (sm) {
|
||||||
|
|||||||
@@ -191,10 +191,18 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Not hovered
|
// Not hovered
|
||||||
&.is-inactive {
|
&.is-hovered {
|
||||||
img {
|
img {
|
||||||
opacity: 0.5;
|
opacity: 1.0 !important;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mouse over collage
|
||||||
|
&.is-hovering {
|
||||||
|
.photo-card img {
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user