PWV-1: Refactoring ohif:studylist package
This commit is contained in:
1 parent
984ef94403
commit
4d79bf84a8
79 files changed
+450
-551
No files matched your search
@@ -36,10 +36,15 @@ class Bounded {
|
||||
options(options={}) {
|
||||
// Process the given options and store it in the instance
|
||||
const { boundingElement, allowResizing } = options;
|
||||
this.boundingElement = boundingElement || window;
|
||||
this.boundingElement = boundingElement;
|
||||
this.$boundingElement = $(this.boundingElement);
|
||||
this.allowResizing = allowResizing;
|
||||
|
||||
// Check for fixed positioning
|
||||
if (this.$element.css('position') === 'fixed') {
|
||||
this.boundingElement = window;
|
||||
}
|
||||
|
||||
// Destroy and initialize again the instance
|
||||
this.destroy();
|
||||
this.init();
|
||||
@@ -55,6 +60,9 @@ class Bounded {
|
||||
|
||||
// Add the bounded class to the element
|
||||
this.$element.addClass('bounded');
|
||||
|
||||
// Trigger the bounding check for the first timepoint
|
||||
setTimeout(() => this.$element.trigger('spatialChanged'));
|
||||
}
|
||||
|
||||
// Destroy this instance, returning the element to its previous state
|
||||
@@ -70,12 +78,26 @@ class Bounded {
|
||||
// Create the result object
|
||||
const result = {};
|
||||
|
||||
// Check if the element is the window
|
||||
if (element === window) {
|
||||
const $window = $(window);
|
||||
const width = $window.outerWidth();
|
||||
const height = $window.outerHeight();
|
||||
return {
|
||||
width,
|
||||
height,
|
||||
x0: 0,
|
||||
y0: 0,
|
||||
x1: width,
|
||||
y1: height
|
||||
};
|
||||
}
|
||||
|
||||
// Get the jQuery object for the element
|
||||
const el = element === window ? window.document.body : element;
|
||||
const $element = $(el);
|
||||
const $element = $(element);
|
||||
|
||||
// Get the element style
|
||||
const style = el.style;
|
||||
const style = element.style;
|
||||
|
||||
// Get the integer numbers for element's width
|
||||
if (style.width && style.width.indexOf('px') > -1) {
|
||||
@@ -91,10 +113,13 @@ class Bounded {
|
||||
result.height = $element.outerHeight();
|
||||
}
|
||||
|
||||
// Get the position property based on the element position CSS attribute
|
||||
const positionProperty = $element.css('position') === 'fixed' ? 'position' : 'offset';
|
||||
|
||||
// Get the element's start position
|
||||
const offset = $element.offset();
|
||||
result.x0 = offset.left;
|
||||
result.y0 = offset.top;
|
||||
const position = $element[positionProperty]();
|
||||
result.x0 = position.left;
|
||||
result.y0 = position.top;
|
||||
|
||||
// Get the element's end position
|
||||
result.x1 = result.x0 + result.width;
|
||||
|
||||
Reference in new issue
Block a user