Reveal Shop header when scrolling past Intro block
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { cartOpen } from '$utils/store'
|
import { cartOpen } from '$utils/store'
|
||||||
|
import { onMount } from 'svelte'
|
||||||
// Components
|
// Components
|
||||||
import Metas from '$components/Metas.svelte'
|
import Metas from '$components/Metas.svelte'
|
||||||
import SiteTitle from '$components/atoms/SiteTitle.svelte'
|
import SiteTitle from '$components/atoms/SiteTitle.svelte'
|
||||||
@@ -14,6 +15,29 @@
|
|||||||
export let locations: any
|
export let locations: any
|
||||||
export let posters: any
|
export let posters: any
|
||||||
export let product: any
|
export let product: any
|
||||||
|
|
||||||
|
let navEl: HTMLElement, introEl: HTMLElement
|
||||||
|
let navObserver: IntersectionObserver
|
||||||
|
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
// Reveal the nav past the Intro
|
||||||
|
navObserver = new IntersectionObserver(entries => {
|
||||||
|
entries.forEach(entry => {
|
||||||
|
navEl.classList.toggle('is-visible', !entry.isIntersecting)
|
||||||
|
})
|
||||||
|
}, {
|
||||||
|
threshold: 0,
|
||||||
|
rootMargin: '0px 0px 0px'
|
||||||
|
})
|
||||||
|
navObserver.observe(introEl)
|
||||||
|
|
||||||
|
|
||||||
|
// Destroy
|
||||||
|
return () => {
|
||||||
|
navObserver && navObserver.unobserve(introEl)
|
||||||
|
}
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Metas
|
<Metas
|
||||||
@@ -27,6 +51,7 @@
|
|||||||
<Cart />
|
<Cart />
|
||||||
{/if}
|
{/if}
|
||||||
<section class="shop-page__intro">
|
<section class="shop-page__intro">
|
||||||
|
<section class="shop-page__intro" bind:this={introEl}>
|
||||||
<a href="/" class="back">
|
<a href="/" class="back">
|
||||||
Back to Houses Of
|
Back to Houses Of
|
||||||
</a>
|
</a>
|
||||||
@@ -67,7 +92,7 @@
|
|||||||
/>
|
/>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<nav class="shop-location">
|
<nav class="shop-location" bind:this={navEl}>
|
||||||
<dl class="shop-location__left">
|
<dl class="shop-location__left">
|
||||||
<dt class="text-label">shop your city</dt>
|
<dt class="text-label">shop your city</dt>
|
||||||
<dd>
|
<dd>
|
||||||
|
|||||||
@@ -29,6 +29,9 @@
|
|||||||
left: 20px;
|
left: 20px;
|
||||||
right: 20px;
|
right: 20px;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
|
transform: translate3d(0, -96px, 0);
|
||||||
|
transition: transform 1s var(--ease-quart);
|
||||||
|
transition-delay: 100ms;
|
||||||
|
|
||||||
@include bp (sm) {
|
@include bp (sm) {
|
||||||
top: 32px;
|
top: 32px;
|
||||||
@@ -36,6 +39,11 @@
|
|||||||
right: 32px;
|
right: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Visible state
|
||||||
|
&.is-visible {
|
||||||
|
transform: translate3d(0,0,0);
|
||||||
|
}
|
||||||
|
|
||||||
// Left
|
// Left
|
||||||
&__left {
|
&__left {
|
||||||
dt {
|
dt {
|
||||||
|
|||||||
Reference in New Issue
Block a user