glue-viz / bqplot-image-gl

Jupyter widget for displaying images with a focus on astronomy
MIT License
19 stars 13 forks source link

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

Closed maartenbreddels closed 3 years ago

maartenbreddels commented 3 years ago

@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[bot] commented 3 years ago

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 commented 3 years ago

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

maartenbreddels commented 3 years ago

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 commented 3 years ago

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