From 2a239d7aab2aa9dc7c6e38f7dc4f4bc5daf24f03 Mon Sep 17 00:00:00 2001 From: saiminh Date: Tue, 3 Oct 2023 17:08:50 +0200 Subject: [PATCH] add a scrollto for mobile focus on textarea --- src/routes/contact/+page.svelte | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/routes/contact/+page.svelte b/src/routes/contact/+page.svelte index 2a381a6..3de8dbd 100644 --- a/src/routes/contact/+page.svelte +++ b/src/routes/contact/+page.svelte @@ -57,6 +57,12 @@ }) }) + let textarea = document.querySelector('textarea') as HTMLElement + + textarea?.addEventListener('focus', () => { + window.scrollTo(0, textarea.offsetTop - 100); + }) + return () => { gsap.killTweensOf('.toCanvas, .lineChildren'); }