From 1065b9dddaa19534e3e6b7fc886fd01ce7bf81d0 Mon Sep 17 00:00:00 2001 From: dusk Date: Sat, 2 Nov 2024 01:10:09 +0300 Subject: [PATCH] fix: put window on top if clicked on, not just being dragged --- src/components/window.svelte | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/window.svelte b/src/components/window.svelte index 7420b24..25767bf 100644 --- a/src/components/window.svelte +++ b/src/components/window.svelte @@ -25,18 +25,23 @@ const isOnMobile = isMobile() const _draggable = isOnMobile ? () => {} : draggable; + + const focusWindow = (node: HTMLElement) => { + $highestZIndex += 1 + node.style.zIndex = $highestZIndex.toString() + } + +
{ - $highestZIndex += 1 - data.currentNode.style.zIndex = $highestZIndex.toString() - }, + onDragStart: (data) => {focusWindow(data.currentNode)}, }} + on:click={(data) => {focusWindow(data.currentTarget)}} class=" relative flex flex-col {sticky ? 'md:sticky md:-top-9' : ''} {center ? "mx-auto" : ""} max-w-screen-md xl:max-w-screen-lg 2xl:max-w-screen-xl min-w-[30ch] lg:min-w-[40ch] w-full md:w-fit [height:fit-content]