-
Notifications
You must be signed in to change notification settings - Fork 206
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
Binding resize method is never called. #456
Comments
I've created an example htmlwidget for quickly testing and verifying this issue: https://github.com/derpylz/testhtmlwidgets160 |
Yikes, thank you for reporting this! |
I'm not sure if it caused by the same reason, but on my machine 1.5.4 produces different sizing results than 1.6.2. I have used test repo from @derpylz. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dear htmlwidgets team,
In version 1.6.0, in the RStudio viewer, the resize method of the binding is never called because the
sizeObj.getWidth()
andsizeObj.getHeight()
functions always return the initial height and width of the element.This is most likely caused by the change in commit 479cfe5cc871434e726b70cd3ef9c17c6fe0b84e. In lines 299-304 and 310-315:
rect is always the boundingClientRect of the element when it was first called, so
rect.width
andrect.height
never update.And because the resizeHandler checks if the width or height have changed from the last values, before calling the resize method of the binding, this never happens.
I've tested this with the example widget (using
htmlwidgets::scaffoldWidget("mywidget")
) in versions 1.5.4 and 1.6.0. Version 1.5.4 contains the old size calculation usingand it correctly calculates the size and calls the resize method. In version 1.6.0 it does not work.
This issue only appears in the Rstudio viewer and not in shiny, as far as I've tested. This makes sense, as the viewer uses separate functions for calculating the dimensions.
I hope this helps, let me know, if I should create a pull request with a fix.
The text was updated successfully, but these errors were encountered: