rmariuzzo / react-new-window

🔲 Pop new windows in React, using `window.open`.
https://rmariuzzo.github.io/react-new-window/
MIT License
446 stars 109 forks source link

New Window can't detect resize event #157

Open pmw1407 opened 1 year ago

pmw1407 commented 1 year ago

I used addEventListener with resize event, but it doesn't work. Other events like mouseup, mousemove, works really well.

  useEffect(() => {
    if (newWindowDocument) {
      newWindowDocument.addEventListener('mouseup', handleMouseUpImage)
      newWindowDocument.addEventListener('mousemove', handleMouseMoveImage)
    }

    return () => {
      newWindowDocument?.removeEventListener('mouseup', handleMouseUpImage)
      newWindowDocument?.removeEventListener('mousemove', handleMouseMoveImage)
    }
  }, [])

  useEffect(() => {
    if (newWindowDocument) {
      newWindowDocument.addEventListener('resize', handleResize)
    }
  }, [scrollRef])

Is it natural that it can't detect it?