Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mouse selection on resize #260

Conversation

DanielArnould
Copy link
Contributor

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.

Update the containerBoundingRect on every mouseDown event. This ensures the container coords are correct on page resize and hopefully fixes issue agentcooper#259 .

This does add some extra overhead, but less than re-rendering the whole element on a page resize.
Replaced `;` with `&&` for chaining copying commands. This means copy-styles will return a fail code if it doesn't copy to esm correctly.
@DanielArnould DanielArnould deleted the fix-mouse-selection-on-resize branch February 28, 2024 10:50
@DanielArnould DanielArnould restored the fix-mouse-selection-on-resize branch February 29, 2024 02:47
@DanielArnould DanielArnould deleted the fix-mouse-selection-on-resize branch February 29, 2024 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant