VTKPlugin icon indicating copy to clipboard operation
VTKPlugin copied to clipboard

Add debounced resize event handler

Open swederik opened this issue 6 years ago • 1 comments

In OHIF we have a resize handler which is debounced to fire 100ms after resizing stops. This prevents needless re-computation / redraws while the browser is being resized (or the device is being rotated to a new orientation).

The VTK plugin should incorporate something similar. Somehow I think it makes more sense to implement this at the plugin level.

You can call volumeViewport.resize(), as is done here:

https://github.com/OHIF/VTKPlugin/blob/8ca0a96648fc18a2491b8e3c3add7dca8e79c365/volumeRendering/main.js#L34-L39

For reference: https://github.com/OHIF/Viewers/blob/master/Packages/ohif-viewerbase/client/lib/classes/ResizeViewportManager.js#L127

swederik avatar Aug 20 '18 16:08 swederik

Make one PR to OHIF/Viewer:

  • ViewportPlugin class should expose overrideable onResize method
  • ViewportPlugin class should setup a resize listener in a method _initResizeListener.
  • ViewportPlugin should have a default value for debounce time in milliseconds, which any subclass could override
  • The handler for this event should check for all plugin divs (similar to https://github.com/OHIF/Viewers/blob/master/Packages/ohif-viewerbase/client/lib/classes/plugins/ViewportPlugin.js#L87) and call onResize with each of them as a the sole argument.

Make another PR to VTKPlugin:

  • Adds onResize which calls volumeViewer.resize()

swederik avatar Sep 13 '18 14:09 swederik