statgen / locuszoom

A Javascript/d3 embeddable plugin for interactively visualizing statistical genetic data from customizable sources.
https://statgen.github.io/locuszoom/
MIT License
156 stars 29 forks source link

Fix plot rendering in tab/collapsible widgets #258

Closed abought closed 3 years ago

abought commented 3 years ago

Many collapsible/tab widgets hide content using display:none. This can lead to plot dimension issues when the LZ plot is first drawn, because changing display mode doesn't trigger the resize listener on a window.

Use a relatively new (2017) browser API to handle this scenario. This should be performance tested in our own sites (like LocalZoom) so that we can monitor errors before shipping as part of a formal release.

Also moved resize listener to after the plot container/svg is defined, to reduce some spurious item undefined errors. (initializeLayout --> initialize)

TODO:

  1. [x] Performance test; identify if listener is firing too often
  2. [x] Handle older browser (check if api is available)
  3. [~] Add unit tests for size behavior
  4. [~] Implement in LocalZoom and collect error monitoring/reports