OHIF-127: Resizing viewport when window gets resized
This commit is contained in:
parent
553eb9e24e
commit
12862aec51
@ -111,11 +111,16 @@ Template.cineDialog.onCreated(() => {
|
|||||||
* ... jQuery's on('resize', func) version which, for some unkown reason
|
* ... jQuery's on('resize', func) version which, for some unkown reason
|
||||||
* ... is currently not working for this portion of code.
|
* ... is currently not working for this portion of code.
|
||||||
* ... Further investigation is necessary.
|
* ... Further investigation is necessary.
|
||||||
|
*
|
||||||
|
* This happens because when an event is attached using jQuery's
|
||||||
|
* you can't get it using vanilla JavaScript, it returns null.
|
||||||
|
* You need to use jQuery for that. So, either you use vanilla JS or jQuery
|
||||||
|
* to get an element's event handler. See viewerMain for more details.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
instance.setResizeHandler = (handler) => {
|
instance.setResizeHandler = handler => {
|
||||||
if (typeof handler === 'function') {
|
if (typeof handler === 'function') {
|
||||||
let origHandler = window.onresize;
|
const origHandler = window.onresize;
|
||||||
instance.origWindowResizeHandler = typeof origHandler === 'function' ? origHandler : null;
|
instance.origWindowResizeHandler = typeof origHandler === 'function' ? origHandler : null;
|
||||||
window.onresize = function (event) {
|
window.onresize = function (event) {
|
||||||
if (typeof origHandler === 'function') {
|
if (typeof origHandler === 'function') {
|
||||||
|
|||||||
@ -1,6 +1,11 @@
|
|||||||
Template.viewerMain.onCreated(() => {
|
Template.viewerMain.onCreated(() => {
|
||||||
// Attach the Window resize listener
|
// Attach the Window resize listener
|
||||||
$(window).on('resize', handleResize);
|
// Don't use jQuery here. "window.onresize" will always be null
|
||||||
|
// If its necessary, check all the code for window.onresize getter
|
||||||
|
// and change it to jQuery._data(window, 'events')['resize'].
|
||||||
|
// Otherwise this function will be probably overrided.
|
||||||
|
// See cineDialog instance.setResizeHandler function
|
||||||
|
window.addEventListener('resize', handleResize);
|
||||||
|
|
||||||
// Create the synchronizer used to update reference lines
|
// Create the synchronizer used to update reference lines
|
||||||
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
OHIF.viewer.updateImageSynchronizer = new cornerstoneTools.Synchronizer('CornerstoneNewImage', cornerstoneTools.updateImageSynchronizer);
|
||||||
@ -24,7 +29,7 @@ Template.viewerMain.onDestroyed(() => {
|
|||||||
log.info('viewerMain onDestroyed');
|
log.info('viewerMain onDestroyed');
|
||||||
|
|
||||||
// Remove the Window resize listener
|
// Remove the Window resize listener
|
||||||
$(window).off('resize', handleResize);
|
window.removeEventListener('resize', handleResize);
|
||||||
|
|
||||||
// Destroy the synchronizer used to update reference lines
|
// Destroy the synchronizer used to update reference lines
|
||||||
OHIF.viewer.updateImageSynchronizer.destroy();
|
OHIF.viewer.updateImageSynchronizer.destroy();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user