Smooth scroll for anchor link
This commit is contained in:
@@ -39,6 +39,20 @@ export const isInViewport = element => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Smooth Scroll
|
||||||
|
*/
|
||||||
|
export const smoothScroll = (event, element = null) => {
|
||||||
|
document.querySelector(element).scrollIntoView({
|
||||||
|
behavior: 'smooth',
|
||||||
|
block: 'start'
|
||||||
|
})
|
||||||
|
event.preventDefault()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Random String Generator
|
** Random String Generator
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
<div class="intro__description style-description">
|
<div class="intro__description style-description">
|
||||||
<p>{$site.description}</p>
|
<p>{$site.description}</p>
|
||||||
|
|
||||||
<Button href="#choose" type="a" className="button" text="Explore locations">
|
<Button type="a" href="#choose" className="button" text="Explore locations" on:click={e => fn.smoothScroll(e, '#choose')}>
|
||||||
<IconGlobeSmall width="22" color="#666" />
|
<IconGlobeSmall width="22" color="#666" />
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user