Add debounced resize event handler
Opened this issue · 1 comments
swederik commented
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:
VTKPlugin/volumeRendering/main.js
Lines 34 to 39 in 8ca0a96
For reference: https://github.com/OHIF/Viewers/blob/master/Packages/ohif-viewerbase/client/lib/classes/ResizeViewportManager.js#L127
swederik commented
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()