From da2c0efefdd02be1ab084acfad833791949f8e00 Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Sat, 5 Oct 2024 11:13:07 -0400 Subject: [PATCH] add ability to click and auto scroll to card from minimap --- src/components/MiniMap.tsx | 41 +++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/components/MiniMap.tsx b/src/components/MiniMap.tsx index 32adc85..423d265 100644 --- a/src/components/MiniMap.tsx +++ b/src/components/MiniMap.tsx @@ -31,6 +31,8 @@ export function MiniMap() { return () => window.removeEventListener('scroll', _handleScroll) }, []) + + return (
{ const note = notes.notes.value[noteKey] + + function _handleItemClick(_e: MouseEvent) { + window.scrollTo({ + left: note.position.x - ((viewportWidth / 2) - (note.dimensions.w / 2)), + top: note.position.y - ((viewportHeight / 2) - (note.dimensions.h / 2)), + behavior: 'smooth' + }) + } + return ( -
) })} -
+
) }