ohif-viewer/Packages/ohif-viewerbase/client/lib/switchToImageRelative.js

19 lines
667 B
JavaScript
Raw Normal View History

import { viewportUtils } from './viewportUtils';
2018-11-12 12:18:48 +01:00
import { cornerstoneTools } from 'meteor/ohif:cornerstone';
const scroll = cornerstoneTools.import('util/scroll');
2015-12-09 15:48:24 +01:00
/**
2018-11-12 12:18:48 +01:00
* This function switches to an image given an element and
2015-12-09 15:48:24 +01:00
* the relative distance from the current image in the stack
2018-11-12 12:18:48 +01:00
*
2015-12-09 15:48:24 +01:00
* e.g. switchToImageRelative(element, -1) to switch to currentImageIdIndex - 1
2018-11-12 12:18:48 +01:00
*
2015-12-09 15:48:24 +01:00
* @param element
* @param {number} [distanceFromCurrentIndex] The image index in the stack to switch to.
*/
export function switchToImageRelative(distanceFromCurrentIndex) {
var element = viewportUtils.getActiveViewportElement();
2018-11-12 12:18:48 +01:00
scroll(element, distanceFromCurrentIndex);
}