Fixing multi-level dropdown issues with window boundaries

This commit is contained in:
Bruno Alves de Faria committed 2017-03-28 18:30:40 -03:00
1 parent e4622aee2d
commit 0cd4714f1a
2 files changed
+35 -5

No files matched your search

+22
View File
@@ -4,3 +4,25 @@ import { Meteor } from 'meteor/meteor';
// Get the UI settings
const ui = Meteor.settings && Meteor.settings.public && Meteor.settings.public.ui;
OHIF.uiSettings = ui || {};
/**
* Get the offset for the given element
*
* @param {Object} element DOM element which will have the offser calculated
* @returns {Object} Object containing the top and left offset
*/
OHIF.ui.getOffset = element => {
let top = 0;
let left = 0;
if (element.offsetParent) {
do {
left += element.offsetLeft;
top += element.offsetTop;
} while (element = element.offsetParent);
}
return {
left,
top
};
};