aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js')
-rwxr-xr-xjs/panels/Materials/materials-library-panel.reel/materials-library-panel.js28
1 files changed, 26 insertions, 2 deletions
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
index aef48230..c3c2a6de 100755
--- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
@@ -116,6 +116,14 @@ exports.MaterialsLibraryPanel = Montage.create(Component, {
116 handleShowMaterialPopup: { 116 handleShowMaterialPopup: {
117 enumerable: false, 117 enumerable: false,
118 value: function (event) { 118 value: function (event) {
119 var piButton = this.application.eventManager.componentClaimingPointer("mouse");
120 if(piButton) {
121 this.selectedMaterialNode = piButton.element;
122 } else {
123 this.selectedMaterialNode = null;
124 }
125
126 this.materialId = event.detail.materialId;
119 this._showMaterialPopup(event.detail); 127 this._showMaterialPopup(event.detail);
120 } 128 }
121 }, 129 },
@@ -209,11 +217,27 @@ exports.MaterialsLibraryPanel = Montage.create(Component, {
209 217
210 willPositionPopup: { 218 willPositionPopup: {
211 value: function(popup, defaultPosition) { 219 value: function(popup, defaultPosition) {
212 var content = popup.content.element, 220 var left,
221 top,
222 content = popup.content.element,
213 contentHt = parseFloat(content.style.height) || content.offsetHeight || 0, 223 contentHt = parseFloat(content.style.height) || content.offsetHeight || 0,
214 contentWd = parseFloat(content.style.width) || content.offsetWidth || 0, 224 contentWd = parseFloat(content.style.width) || content.offsetWidth || 0,
215 pt = webkitConvertPointFromNodeToPage(this.selectedMaterialNode, new WebKitPoint(0, 0)); 225 pt = webkitConvertPointFromNodeToPage(this.selectedMaterialNode, new WebKitPoint(0, 0));
216 return {top: pt.y - contentHt + 10, left: pt.x - contentWd + 10}; 226
227 if(!pt) {
228 return defaultPosition;
229 }
230
231 top = pt.y - contentHt + 10;
232 if(top < 0) {
233 top = 0;
234 }
235 left = pt.x - contentWd + 10;
236 if(left < 0) {
237 left = 0;
238 }
239
240 return {top:top, left:left};
217 } 241 }
218 } 242 }
219}); 243});