From d6504ce0ce3069c9e9a2e0d42d3bb35f55d817fd Mon Sep 17 00:00:00 2001 From: Triston Armstrong Date: Thu, 10 Oct 2024 23:08:47 -0400 Subject: [PATCH] feat(text): fix bug trying to resize text moving element --- src/components/ImageCard.tsx | 14 ++++++--- src/components/TextItem.tsx | 59 ++++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 28 deletions(-) diff --git a/src/components/ImageCard.tsx b/src/components/ImageCard.tsx index 1f750ff..3601c73 100644 --- a/src/components/ImageCard.tsx +++ b/src/components/ImageCard.tsx @@ -88,6 +88,12 @@ export function ImageCard({ key: itemKey, data: item }: ImageCard.ImageCardProps window.removeEventListener('mouseup', _handleResizeMouseUp) } + function _handleClose(_e: Event) { + ImagesSignal.default.removeImage(item.id) + ImagesSignal.default.images.notify() + debounceLSUpdate() + } + return (
- +
diff --git a/src/components/TextItem.tsx b/src/components/TextItem.tsx index 8a61688..a12bc49 100644 --- a/src/components/TextItem.tsx +++ b/src/components/TextItem.tsx @@ -47,8 +47,9 @@ export function TextItem({ key: itemKey, data: item }: TextItem.TextCardProps) { } function _handleMouseDown(e: MouseEvent) { - e.preventDefault() focusedItem.value = itemKey + e.preventDefault() + e.stopPropagation() offsetX.current = e.offsetX offsetY.current = e.offsetY pressed.value = true @@ -69,23 +70,24 @@ export function TextItem({ key: itemKey, data: item }: TextItem.TextCardProps) { function _handleResizeMouseDown(e: MouseEvent) { + e.stopPropagation() initialResizeX.current = e.pageX pressed.value = true window.addEventListener('mousemove', _handleResizeMove) window.addEventListener('mouseup', _handleResizeMouseUp) } - function _handleResizeMouseUp() { + function _handleResizeMouseUp(_e: MouseEvent) { pressed.value = false - updateLocalStorage() window.removeEventListener('mousemove', _handleResizeMove) window.removeEventListener('mouseup', _handleResizeMouseUp) + updateLocalStorage() } return (
-
+
{item.contents}
- - - + + +
) } +function ExpandIcon({ cb, item }: { + cb: ((this: GlobalEventHandlers, ev: MouseEvent) => any) | null | undefined, + item: TextSignal.TextCardType +}) { + + return ( + + + + ) +}