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

feat: ViewListener to get dimensions of DOM elements in all views #57

Merged
merged 1 commit into from
May 20, 2021

Conversation

maartenbreddels
Copy link
Collaborator

@astrofrog I did not test this a lot, but you can try out if this works as you expect:

from bqplot_image_gl.viewlistener import ViewListener
import ipywidgets as widgets
slider = widgets.FloatSlider()
slider
vl = ViewListener(widget=slider, css_selector=".ui-slider-handle")

image

@codecov
Copy link

codecov bot commented May 11, 2021

Codecov Report

Merging #57 (249fdf5) into master (9d0a827) will decrease coverage by 8.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #57      +/-   ##
==========================================
- Coverage   58.00%   50.00%   -8.00%     
==========================================
  Files           5        6       +1     
  Lines         100      116      +16     
==========================================
  Hits           58       58              
- Misses         42       58      +16     
Impacted Files Coverage Δ
bqplot_image_gl/viewlistener.py 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 9d0a827...249fdf5. Read the comment docs.

@astrofrog
Copy link
Member

Nice! I'll play with this to see if it works nicely for determining aspect ratios.

@maartenbreddels
Copy link
Collaborator Author

For bqplot, this seems to work well:

vl = ViewListener(widget=figure, css_selector=".svg-figure > g")

As you can see in the screenshot:
image

the second viewlistener has the correct dimensions.

Not sure why the JS exception occurs.

@maartenbreddels maartenbreddels marked this pull request as ready for review May 18, 2021 10:52
@maartenbreddels
Copy link
Collaborator Author

After some bug hunting and polishing, I think this is ready to go.

Copy link
Member

@astrofrog astrofrog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to work nicely! I think we should just merge, and I'll open an issue if I run into problems when implementing the aspect ratio stuff in glupyter.

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.

None yet

2 participants