Fixing enlarged active viewport issue

This commit is contained in:
Bruno Alves de Faria 2016-08-20 10:48:01 -03:00
parent 479e420179
commit 2d6933fe66
2 changed files with 27 additions and 11 deletions

View File

@ -513,16 +513,32 @@ Template.imageViewerViewport.onDestroyed(function() {
}); });
Template.imageViewerViewport.events({ Template.imageViewerViewport.events({
'ActivateViewport .imageViewerViewport': function(e) { 'ActivateViewport .imageViewerViewport'(event) {
log.info('imageViewerViewport ActivateViewport'); log.info('imageViewerViewport ActivateViewport');
setActiveViewport(e.currentTarget); setActiveViewport(event.currentTarget);
}, },
'click .imageViewerViewport': function(e) {
var viewportIndex = $('.imageViewerViewport').index(e.currentTarget); 'click .imageViewerViewport'(event) {
Session.set('activeViewport', viewportIndex); setActiveViewport(event.currentTarget);
}, },
'CornerstoneToolsMouseDoubleClick .imageViewerViewport, CornerstoneToolsDoubleTap .imageViewerViewport': function(e) {
var viewportIndex = $('.imageViewerViewport').index(e.currentTarget); 'CornerstoneToolsMouseDoubleClick .imageViewerViewport, CornerstoneToolsDoubleTap .imageViewerViewport'(event) {
// Get the double clicked viewport index
const viewportIndex = $('.imageViewerViewport').index(event.currentTarget);
// Enlarge the double clicked viewport
layoutManager.toggleEnlargement(viewportIndex); layoutManager.toggleEnlargement(viewportIndex);
// Wait for DOM re-rendering and update the active viewport
Tracker.afterFlush(() => {
// Check if the viewer is zoomed
if (layoutManager.isZoomed) {
// Set the active viewport as the only one visible
setActiveViewport($('.imageViewerViewport')[0]);
} else {
// Set the active viewport as the previous zoomed viewport
setActiveViewport($('.imageViewerViewport').eq(window.layoutManager.zoomedViewportIndex));
}
});
} }
}); });

View File

@ -7,7 +7,7 @@ setActiveViewport = function(element) {
// When an ActivateViewport event is fired, update the Meteor Session // When an ActivateViewport event is fired, update the Meteor Session
// with the viewport index that it was fired from. // with the viewport index that it was fired from.
Session.set("activeViewport", viewportIndex); Session.set('activeViewport', viewportIndex);
// Add the 'active' class to the parent container to highlight the active viewport // Add the 'active' class to the parent container to highlight the active viewport
$('#imageViewerViewports .viewportContainer').removeClass('active'); $('#imageViewerViewports .viewportContainer').removeClass('active');
@ -21,5 +21,5 @@ setActiveViewport = function(element) {
// Set the div to focused, so keypress events are handled // Set the div to focused, so keypress events are handled
//$(element).focus(); //$(element).focus();
//.focus() event breaks in FF&IE //.focus() event breaks in FF&IE
$(element).triggerHandler("focus"); $(element).triggerHandler('focus');
}; };