diff options
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/body-controller.js | 40 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js | 13 |
2 files changed, 52 insertions, 1 deletions
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js index 839d0787..14aeae24 100755 --- a/js/controllers/elements/body-controller.js +++ b/js/controllers/elements/body-controller.js | |||
@@ -51,5 +51,45 @@ exports.BodyController = Montage.create(ElementController, { | |||
51 | return dist; | 51 | return dist; |
52 | } | 52 | } |
53 | } | 53 | } |
54 | }, | ||
55 | |||
56 | getMatrix: { | ||
57 | value: function(el) { | ||
58 | if(el.elementModel && el.elementModel.props3D && el.elementModel.props3D.matrix3d) | ||
59 | { | ||
60 | return el.elementModel.props3D.matrix3d.slice(0); | ||
61 | } | ||
62 | else | ||
63 | { | ||
64 | var mat; | ||
65 | |||
66 | if (el) | ||
67 | { | ||
68 | mat = this.application.ninja.stylesController.getMatrixFromElement(el, true); | ||
69 | if (!mat) { | ||
70 | mat = Matrix.I(4); | ||
71 | } | ||
72 | |||
73 | var zoom = this.application.ninja.elementMediator.getProperty(el, "zoom"); | ||
74 | if (zoom) | ||
75 | { | ||
76 | zoom = Number(zoom); | ||
77 | if (zoom != 1) | ||
78 | { | ||
79 | var zoomMat = Matrix.create( [ | ||
80 | [ zoom, 0, 0, 0], | ||
81 | [ 0, zoom, 0, 0], | ||
82 | [ 0, 0, zoom, 0], | ||
83 | [ 0, 0, 0, 1] | ||
84 | ] ); | ||
85 | glmat4.multiply( zoomMat, mat, mat ); | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | |||
90 | el.elementModel.props3D.matrix3d = mat; | ||
91 | return mat; | ||
92 | } | ||
93 | } | ||
54 | } | 94 | } |
55 | }); | 95 | }); |
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 452d09f1..ea5fe4af 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -11,7 +11,18 @@ exports.ElementController = Montage.create(Component, { | |||
11 | 11 | ||
12 | addElement: { | 12 | addElement: { |
13 | value: function(el, styles) { | 13 | value: function(el, styles) { |
14 | this.application.ninja.currentDocument.documentRoot.appendChild(el); | 14 | if(this.application.ninja.timeline.currentLayerSelected) { |
15 | var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); | ||
16 | |||
17 | if(selectedLayerIndex === 0) { | ||
18 | this.application.ninja.currentDocument.documentRoot.appendChild(el); | ||
19 | } else { | ||
20 | var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.elementsList[0]; | ||
21 | element.parentNode.insertBefore(el, element.nextSibling); | ||
22 | } | ||
23 | } else { | ||
24 | this.application.ninja.currentDocument.documentRoot.appendChild(el); | ||
25 | } | ||
15 | // Nested elements - TODO make sure the CSS is correct before nesting elements | 26 | // Nested elements - TODO make sure the CSS is correct before nesting elements |
16 | // this.application.ninja.currentSelectedContainer.appendChild(el); | 27 | // this.application.ninja.currentSelectedContainer.appendChild(el); |
17 | if(styles) { | 28 | if(styles) { |