Always fit context menu to the screen.
This commit is contained in:
parent
9405aff3dd
commit
d59a0c0a77
@ -22,7 +22,7 @@ OV.ShowListPopup = function (items, callbacks)
|
||||
if (items.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
let popup = new OV.ListPopup ();
|
||||
popup.Init (() => {
|
||||
return callbacks.calculatePosition (popup.GetContentDiv ());
|
||||
@ -49,3 +49,33 @@ OV.ShowListPopup = function (items, callbacks)
|
||||
popup.Show ();
|
||||
return popup;
|
||||
};
|
||||
|
||||
OV.CalculatePopupPositionToElementBottomRight = function (elementDiv, contentDiv)
|
||||
{
|
||||
let offset = elementDiv.offset ();
|
||||
return {
|
||||
x : offset.left + elementDiv.outerWidth (false),
|
||||
y : offset.top + elementDiv.outerHeight (false) - contentDiv.outerHeight (true)
|
||||
};
|
||||
};
|
||||
|
||||
OV.CalculatePopupPositionToScreen = function (globalMouseCoordinates, contentDiv)
|
||||
{
|
||||
let windowObj = $(window);
|
||||
let windowWidth = windowObj.outerWidth ();
|
||||
let windowHeight = windowObj.outerHeight ();
|
||||
let left = globalMouseCoordinates.x;
|
||||
let top = globalMouseCoordinates.y;
|
||||
let right = left + contentDiv.outerWidth (true);
|
||||
let bottom = top + contentDiv.outerHeight (true);
|
||||
if (right > windowWidth) {
|
||||
left = left - (right - windowWidth);
|
||||
}
|
||||
if (bottom > windowHeight) {
|
||||
top = top - (bottom - windowHeight);
|
||||
}
|
||||
return {
|
||||
x : left,
|
||||
y : top
|
||||
};
|
||||
};
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
OV.FeatureSet =
|
||||
{
|
||||
SettingsPanel : false,
|
||||
ContextMenu : false
|
||||
ContextMenu : true
|
||||
};
|
||||
|
||||
@ -43,11 +43,7 @@ OV.NavigatorInfoPanel = class
|
||||
}
|
||||
this.popup = OV.ShowListPopup (meshItems, {
|
||||
calculatePosition : (contentDiv) => {
|
||||
let offset = button.offset ();
|
||||
return {
|
||||
x : offset.left + button.outerWidth (false),
|
||||
y : offset.top + button.outerHeight (false) - contentDiv.outerHeight (true)
|
||||
};
|
||||
return OV.CalculatePopupPositionToElementBottomRight (button, contentDiv);
|
||||
},
|
||||
onHoverStart : (index) => {
|
||||
const meshItem = usedByMeshes[index];
|
||||
@ -84,11 +80,7 @@ OV.NavigatorInfoPanel = class
|
||||
this.CreateButton (this.parentDiv, materialsText, (button) => {
|
||||
this.popup = OV.ShowListPopup (materialItems, {
|
||||
calculatePosition : (contentDiv) => {
|
||||
let offset = button.offset ();
|
||||
return {
|
||||
x : offset.left + button.outerWidth (false),
|
||||
y : offset.top + button.outerHeight (false) - contentDiv.outerHeight (true)
|
||||
};
|
||||
return OV.CalculatePopupPositionToElementBottomRight (button, contentDiv);
|
||||
},
|
||||
onClick : (index) => {
|
||||
let usedMaterial = usedMaterials[index];
|
||||
|
||||
@ -147,7 +147,7 @@ OV.Website = class
|
||||
if (!OV.FeatureSet.ContextMenu) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let meshUserData = this.viewer.GetMeshUserDataUnderMouse (mouseCoordinates);
|
||||
let items = [];
|
||||
if (meshUserData === null) {
|
||||
@ -183,7 +183,7 @@ OV.Website = class
|
||||
}
|
||||
},
|
||||
{
|
||||
name : isMeshIsolated ? 'Remove mesh isolation' : 'Isolate mesh',
|
||||
name : isMeshIsolated ? 'Remove isolation' : 'Isolate mesh',
|
||||
onClick : () => {
|
||||
this.navigator.IsolateMesh (meshIndex);
|
||||
}
|
||||
@ -192,11 +192,8 @@ OV.Website = class
|
||||
}
|
||||
this.dialog = OV.ShowListPopup (items, {
|
||||
calculatePosition : (contentDiv) => {
|
||||
return {
|
||||
x : globalMouseCoordinates.x,
|
||||
y : globalMouseCoordinates.y
|
||||
};
|
||||
},
|
||||
return OV.CalculatePopupPositionToScreen (globalMouseCoordinates, contentDiv);
|
||||
},
|
||||
onClick : (index) => {
|
||||
let clickedItem = items[index];
|
||||
clickedItem.onClick ();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user