Skip to content

Commit

Permalink
Reposition on window resize
Browse files Browse the repository at this point in the history
  • Loading branch information
TetraTsunami committed Jun 1, 2024
1 parent bb0f967 commit 26e1127
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/contents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ const SummaryPopup = () => {
})

// Dismiss on scroll (the popup doesn't move with the page)
// Dismiss on clicking outside
useEffect(() => {
const callback = async (event: { target: Element }) => {
if (event.target.tagName !== "PLASMO-CSUI") {
Expand All @@ -299,24 +300,26 @@ const SummaryPopup = () => {
}
// @ts-ignore ts(2769)
window.addEventListener("scroll", callback)
// @ts-ignore ts(2769)
document.addEventListener("click", callback)
return () => {
// @ts-ignore ts(2769)
window.removeEventListener("scroll", callback)
// @ts-ignore ts(2769)
document.removeEventListener("click", callback)
}
})

// Dismiss on clicking outside
// Reposition on window resize
useEffect(() => {
const callback = async (event: { target: Element }) => {
if (event.target.tagName !== "PLASMO-CSUI") {
closePopup()
const callback = async () => {
if (popupTarget) {
movePopup(popupTarget)
}
}
// @ts-ignore ts(2769)
document.addEventListener("click", callback)
window.addEventListener("resize", callback)
return () => {
// @ts-ignore ts(2769)
document.removeEventListener("click", callback)
window.removeEventListener("resize", callback)
}
})

Expand Down

0 comments on commit 26e1127

Please sign in to comment.