diff --git a/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js b/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js index ee69883..86781e9 100644 --- a/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js +++ b/src/app/WardrobePage/support/ItemLayerSupportUploadModal.js @@ -211,6 +211,8 @@ function ItemLayerSupportScreenshotStep({ itemLayer, step, onUpload }) { Step {step}: Take a screenshot of exactly the 600×600 Flash region, then upload it below. +
+ The border will turn green once the entire region is in view.
{ + const region = regionRef.current; + if (!region) { + return; + } + + const scrollParent = region.closest(".chakra-modal__overlay"); + if (!scrollParent) { + throw new Error(`could not find .chakra-modal__overlay scroll parent`); + } + + const onMountAndOnScroll = () => { + const regionBox = region.getBoundingClientRect(); + const scrollParentBox = scrollParent.getBoundingClientRect(); + const isVisible = + regionBox.left > scrollParentBox.left && + regionBox.right < scrollParentBox.right && + regionBox.top > scrollParentBox.top && + regionBox.bottom < scrollParentBox.bottom; + setIsVisible(isVisible); + }; + + onMountAndOnScroll(); + + scrollParent.addEventListener("scroll", onMountAndOnScroll); + + return () => scrollParent.removeEventListener("scroll", onMountAndOnScroll); + }, [regionRef.current]); + + let borderColor; + if (isVisible === null) { + borderColor = "gray.400"; + } else if (isVisible === false) { + borderColor = "red.400"; + } else if (isVisible === true) { + borderColor = "green.400"; + } + return (