react-pdf-highlighter
react-pdf-highlighter copied to clipboard
Fix mouse selection on resize
This is just a simple fix for issue #259 . Before, the containerBounderRect
in MouseSelection
was only being set whenever containerCoords
was first called. Since MouseSelection doesn't re-mount on a resize, containerBoundingRect
doesn't get reset to null and then re-initialised, breaking the calculated coords.
All this fix does is set containerBoundingRect
to the latest clientRect whenever mouseDown is called. This adds some extra unnecessary overhead, but the alternative is resetting the variable on resize from the PdfHighlighter or remounting the MouseSelection entirely. I may have forgotten another way, though 😂.
I also just made a very small change to build:copy-styles
to make it safer.