Use sveltekit:noscroll/prefetch on internal links

This commit is contained in:
2021-11-17 19:25:40 +01:00
parent 8a53079fa1
commit ac40eedb2f
10 changed files with 16 additions and 12 deletions

View File

@@ -7,7 +7,9 @@
export let url: string export let url: string
</script> </script>
<a href={url} class="box-cta"> <a href={url} class="box-cta"
sveltekit:noscroll sveltekit:prefetch={url.includes('http') ? true : undefined}
>
<div class="icon"> <div class="icon">
<Icon icon={icon} label={alt} /> <Icon icon={icon} label={alt} />
</div> </div>

View File

@@ -37,7 +37,7 @@
<div class="newsletter-form__bottom"> <div class="newsletter-form__bottom">
{#if past} {#if past}
<a href="/subscribe" class="past-issues"> <a href="/subscribe" class="past-issues" sveltekit:noscroll sveltekit:prefetch>
<svg width="20" height="16" viewBox="0 0 20 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-label="Newsletter icon"> <svg width="20" height="16" viewBox="0 0 20 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg" aria-label="Newsletter icon">
<path fill-rule="evenodd" clip-rule="evenodd" d="M18 2.346H2a.5.5 0 0 0-.5.5v11.102a.5.5 0 0 0 .5.5h16a.5.5 0 0 0 .5-.5V2.846a.5.5 0 0 0-.5-.5ZM2 .846a2 2 0 0 0-2 2v11.102a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2.846a2 2 0 0 0-2-2H2Zm13.75 4.25h-2v3h2v-3Zm-2-1a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2ZM3.5 6.5a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6Zm.25 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5Zm1.25 2a.5.5 0 0 0 0 1h6a.5.5 0 1 0 0-1H5Z" /> <path fill-rule="evenodd" clip-rule="evenodd" d="M18 2.346H2a.5.5 0 0 0-.5.5v11.102a.5.5 0 0 0 .5.5h16a.5.5 0 0 0 .5-.5V2.846a.5.5 0 0 0-.5-.5ZM2 .846a2 2 0 0 0-2 2v11.102a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V2.846a2 2 0 0 0-2-2H2Zm13.75 4.25h-2v3h2v-3Zm-2-1a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2ZM3.5 6.5a.5.5 0 0 0 0 1h6a.5.5 0 0 0 0-1h-6Zm.25 3a.5.5 0 0 1 .5-.5h6a.5.5 0 0 1 0 1h-6a.5.5 0 0 1-.5-.5Zm1.25 2a.5.5 0 0 0 0 1h6a.5.5 0 1 0 0-1H5Z" />
</svg> </svg>

View File

@@ -62,7 +62,7 @@
<a href="/{location.country.slug}/{location.slug}" <a href="/{location.country.slug}/{location.slug}"
on:mousemove={handleMouseMove} on:mousemove={handleMouseMove}
on:mouseleave={handleMouseLeave} on:mouseleave={handleMouseLeave}
sveltekit-noscroll sveltekit:noscroll
> >
<Image <Image
class="location__flag" class="location__flag"

View File

@@ -12,7 +12,7 @@
<div class="poster"> <div class="poster">
{#if image} {#if image}
<a href="/shop/poster-{location.slug}"> <a href="/shop/poster-{location.slug}" sveltekit:noscroll sveltekit:prefetch>
<Image <Image
id={image.id} id={image.id}
sizeKey="product" sizeKey="product"

View File

@@ -58,7 +58,9 @@
<ul> <ul>
{#each links as { icon, iconLabel, url, text }} {#each links as { icon, iconLabel, url, text }}
<li> <li>
<a href={url} on:click={toggleSwitcher} sveltekit:prefetch> <a href={url} on:click={toggleSwitcher}
sveltekit:noscroll sveltekit:prefetch
>
<Icon class="icon" icon={icon} label={iconLabel} /> <Icon class="icon" icon={icon} label={iconLabel} />
<span>{text}</span> <span>{text}</span>
</a> </a>

View File

@@ -10,7 +10,7 @@
<footer class="footer"> <footer class="footer">
<div class="container grid"> <div class="container grid">
<a href="/" class="footer__title" sveltekit:prefetch> <a href="/" class="footer__title" sveltekit:prefetch sveltekit:noscroll>
<SiteTitle tag="div" /> <SiteTitle tag="div" />
</a> </a>
@@ -18,7 +18,7 @@
<ul> <ul>
{#each footer_links as { title, slug }} {#each footer_links as { title, slug }}
<li> <li>
<a href="/{slug}" class="link-3d" sveltekit:prefetch> <a href="/{slug}" class="link-3d" sveltekit:prefetch sveltekit:noscroll>
<SplitText text={title} clone={true} /> <SplitText text={title} clone={true} />
</a> </a>
</li> </li>

View File

@@ -199,7 +199,7 @@
<h1 class="title-medium">{currentPhoto.title}</h1> <h1 class="title-medium">{currentPhoto.title}</h1>
<div class="detail text-info"> <div class="detail text-info">
<a href="/{location.country.slug}/{location.slug}"> <a href="/{location.country.slug}/{location.slug}" sveltekit:prefetch sveltekit:noscroll>
<Icon class="icon" icon="map-pin" label="Map pin" /> <Icon class="icon" icon="map-pin" label="Map pin" />
<span> <span>
{#if currentPhoto.city} {#if currentPhoto.city}

View File

@@ -67,7 +67,7 @@
<ul> <ul>
{#each location as { location_id: { name, slug: slugLocation, country: { slug: slugCountry }}}, index} {#each location as { location_id: { name, slug: slugLocation, country: { slug: slugCountry }}}, index}
<li> <li>
<a href="/{slugCountry}/{slugLocation}">{name}</a> <a href="/{slugCountry}/{slugLocation}" sveltekit:noscroll>{name}</a>
</li> </li>
{/each} {/each}
</ul> </ul>

View File

@@ -296,7 +296,7 @@
<div class="photos__grid"> <div class="photos__grid">
{#each photos as { image, slug, location, title, city }, index} {#each photos as { image, slug, location, title, city }, index}
<figure class="photo shadow-photo"> <figure class="photo shadow-photo">
<a href="/{location.country.slug}/{location.slug}/{slug}"> <a href="/{location.country.slug}/{location.slug}/{slug}" sveltekit:prefetch sveltekit:noscroll>
<Image <Image
id={image.id} id={image.id}
sizeKey="photo-grid" sizeKey="photo-grid"

View File

@@ -62,7 +62,7 @@
<section class="shop-page__intro" bind:this={introEl}> <section class="shop-page__intro" bind:this={introEl}>
<div class="top container"> <div class="top container">
<a href="/" class="back"> <a href="/" class="back" sveltekit:noscroll>
<svg width="5" height="8" viewBox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="5" height="8" viewBox="0 0 5 8" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 1 1 4l3 3" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/> <path d="M4 1 1 4l3 3" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
</svg> </svg>
@@ -83,7 +83,7 @@
<ul> <ul>
{#each $shopLocations as { name, slug }} {#each $shopLocations as { name, slug }}
<li class:is-active={slug === product.location.slug}> <li class:is-active={slug === product.location.slug}>
<a href="/shop/poster-{slug}" sveltekit:noscroll sveltekit:prefetch> <a href="/shop/poster-{slug}" sveltekit:prefetch sveltekit:noscroll>
{name} {name}
</a> </a>
</li> </li>