Fixing mouse interaction with label dialog

This commit is contained in:
Bruno Alves de Faria committed 2017-11-21 15:10:12 -02:00
1 parent 7d2577b06f
commit f4a77d6f4d
4 files changed
+69 -19

No files matched your search

+15 -10
View File
@@ -172,29 +172,33 @@ class Bounded {
}
};
this.cssTransformHandler = (elementInfo, boundingInfo) => {
this.getCSSTranslate = () => {
const matrixToArray = str => str.match(/(-?[0-9\.]+)/g);
const transformMatrix = matrixToArray(this.$positionElement.css('transform')) || [];
let translateX = parseFloat(transformMatrix[4]) || 0;
let translateY = parseFloat(transformMatrix[5]) || 0;
return {
x: parseFloat(transformMatrix[4]) || 0,
y: parseFloat(transformMatrix[5]) || 0
};
};
this.cssTransformHandler = (elementInfo, boundingInfo, translate) => {
if (elementInfo.x1 > boundingInfo.x1) {
translateX -= elementInfo.x1 - boundingInfo.x1;
translate.x -= elementInfo.x1 - boundingInfo.x1;
}
if (elementInfo.y1 > boundingInfo.y1) {
translateY -= elementInfo.y1 - boundingInfo.y1;
translate.y -= elementInfo.y1 - boundingInfo.y1;
}
if (elementInfo.x0 < boundingInfo.x0) {
translateX += boundingInfo.x0 - elementInfo.x0;
translate.x += boundingInfo.x0 - elementInfo.x0;
}
if (elementInfo.y0 < boundingInfo.y0) {
translateY += boundingInfo.y0 - elementInfo.y0;
translate.y += boundingInfo.y0 - elementInfo.y0;
}
const translation = `translate(${translateX}px, ${translateY}px)`;
const translation = `translate(${translate.x}px, ${translate.y}px)`;
OHIF.ui.styleProperty.set(this.positionElement, 'transform', translation);
};
@@ -205,8 +209,9 @@ class Bounded {
const boundingInfo = Bounded.spatialInfo(boundingElement, boundingElement);
// Check if CSS positioning or transform will be used
if (useTransform) {
this.cssTransformHandler(elementInfo, boundingInfo);
const translate = this.getCSSTranslate();
if (useTransform && (translate.x || translate.y)) {
this.cssTransformHandler(elementInfo, boundingInfo, translate);
} else {
this.cssPositionHandler(elementInfo, boundingInfo);
}