From ae4ea7f4fa3b0ba1177c31cf8f0c577829861276 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fe=CC=81lix=20Pe=CC=81ault?= Date: Mon, 11 Jul 2022 16:42:28 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Use=20smooth=20scroll=20function=20?= =?UTF-8?q?to=20navigate=20to=20anchor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using a eased RAF function to scroll to a specific target Avoid using `scrollIntoView` or smooth behavior as it doesn't work on Safari and others. --- src/components/molecules/Poster.svelte | 8 +-- .../molecules/ShopLocationSwitcher.svelte | 3 ++ src/components/organisms/ShopHeader.svelte | 3 +- src/routes/index.svelte | 7 +-- src/utils/functions/easing.ts | 9 ++++ src/utils/functions/index.ts | 50 +++++++++++++++++++ 6 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 src/utils/functions/easing.ts diff --git a/src/components/molecules/Poster.svelte b/src/components/molecules/Poster.svelte index 9be8908..f13e0da 100644 --- a/src/components/molecules/Poster.svelte +++ b/src/components/molecules/Poster.svelte @@ -5,6 +5,7 @@ diff --git a/src/components/organisms/ShopHeader.svelte b/src/components/organisms/ShopHeader.svelte index 7c625f1..9c49d81 100644 --- a/src/components/organisms/ShopHeader.svelte +++ b/src/components/organisms/ShopHeader.svelte @@ -6,6 +6,7 @@ import { getContext, onMount } from 'svelte' import anime, { type AnimeTimelineInstance } from 'animejs' import { cartOpen } from '$utils/stores/shop' + import { smoothScroll } from '$utils/functions' // Components import Image from '$components/atoms/Image.svelte' import ButtonCart from '$components/atoms/ButtonCart.svelte' @@ -106,7 +107,7 @@