diff options
author | Nivesh Rajbhandari | 2012-05-16 13:06:34 -0700 |
---|---|---|
committer | Nivesh Rajbhandari | 2012-05-16 13:06:34 -0700 |
commit | 4f46850b376b2d428a3d9415b1dc69b36b875a2c (patch) | |
tree | 8ff2c827261e0203d2214e9f36bb939e19947871 | |
parent | 23bf5db97fb24afdb14d02faac1136fc04137e96 (diff) | |
download | ninja-4f46850b376b2d428a3d9415b1dc69b36b875a2c.tar.gz |
Automatically add scrollbars when moving content to negative space.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rwxr-xr-x | js/helper-classes/3D/draw-utils.js | 41 | ||||
-rwxr-xr-x | js/stage/stage.reel/stage.js | 31 |
2 files changed, 64 insertions, 8 deletions
diff --git a/js/helper-classes/3D/draw-utils.js b/js/helper-classes/3D/draw-utils.js index b53ac4ad..b268b8f0 100755 --- a/js/helper-classes/3D/draw-utils.js +++ b/js/helper-classes/3D/draw-utils.js | |||
@@ -245,16 +245,45 @@ var DrawUtils = exports.DrawUtils = Montage.create(Component, { | |||
245 | } | 245 | } |
246 | var els = event.detail.data.els; | 246 | var els = event.detail.data.els; |
247 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { | 247 | if(els && this._shouldUpdatePlanes(event.detail.data.prop)) { |
248 | var len = els.length; | 248 | var len = els.length, |
249 | stage = this.application.ninja.stage, | ||
250 | minLeft = stage.userPaddingLeft, | ||
251 | minTop = stage.userPaddingTop, | ||
252 | docLeft = stage.documentOffsetLeft, | ||
253 | docTop = stage.documentOffsetTop, | ||
254 | l, | ||
255 | t, | ||
256 | plane, | ||
257 | changed = false; | ||
249 | for(var i=0; i < len; i++) { | 258 | for(var i=0; i < len; i++) { |
250 | if(els[i].elementModel.props3D.elementPlane) { | 259 | plane = els[i].elementModel.props3D.elementPlane; |
251 | els[i].elementModel.props3D.elementPlane.init(); | 260 | if(plane) { |
261 | plane.init(); | ||
262 | l = plane._rect.m_left - docLeft; | ||
263 | t = plane._rect.m_top - docTop; | ||
264 | if(l < minLeft) { | ||
265 | minLeft = l; | ||
266 | } | ||
267 | if(t < minTop) { | ||
268 | minTop = t; | ||
269 | } | ||
252 | } | 270 | } |
253 | } | 271 | } |
254 | 272 | ||
255 | this.application.ninja.stage.layout.draw(); | 273 | if(minLeft !== stage.userPaddingLeft) { |
256 | this.drawWorkingPlane(); | 274 | stage.userPaddingLeft = minLeft; |
257 | this.draw3DCompass(); | 275 | changed = true; |
276 | } | ||
277 | if(minTop !== stage.userPaddingTop) { | ||
278 | stage.userPaddingTop = minTop; | ||
279 | changed = true; | ||
280 | } | ||
281 | |||
282 | if(!changed) { | ||
283 | stage.layout.draw(); | ||
284 | this.drawWorkingPlane(); | ||
285 | this.draw3DCompass(); | ||
286 | } | ||
258 | } | 287 | } |
259 | } | 288 | } |
260 | }, | 289 | }, |
diff --git a/js/stage/stage.reel/stage.js b/js/stage/stage.reel/stage.js index 125155d8..05376527 100755 --- a/js/stage/stage.reel/stage.js +++ b/js/stage/stage.reel/stage.js | |||
@@ -187,6 +187,33 @@ exports.Stage = Montage.create(Component, { | |||
187 | enumerable : false | 187 | enumerable : false |
188 | }, | 188 | }, |
189 | 189 | ||
190 | _userPaddingLeft: { value: 0 }, | ||
191 | _userPaddingTop: { value: 0 }, | ||
192 | |||
193 | userPaddingLeft: { | ||
194 | get: function() { return this._userPaddingLeft; }, | ||
195 | set: function(value) { | ||
196 | this._userPaddingLeft = value; | ||
197 | this._documentOffsetLeft = -value; | ||
198 | this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], | ||
199 | "padding-left", -value + "px", true); | ||
200 | this.userContentLeft = this._documentOffsetLeft; | ||
201 | this.updatedStage = true; | ||
202 | } | ||
203 | }, | ||
204 | |||
205 | userPaddingTop: { | ||
206 | get: function() { return this._userPaddingTop; }, | ||
207 | set: function(value) { | ||
208 | this._userPaddingTop = value; | ||
209 | this._documentOffsetTop = -value; | ||
210 | this.application.ninja.stylesController.setElementStyle(this._documentRoot.ownerDocument.getElementsByTagName("HTML")[0], | ||
211 | "padding-top", -value + "px", true); | ||
212 | this.userContentTop = this._documentOffsetTop; | ||
213 | this.updatedStage = true; | ||
214 | } | ||
215 | }, | ||
216 | |||
190 | willDraw: { | 217 | willDraw: { |
191 | value: function() { | 218 | value: function() { |
192 | if(this.resizeCanvases) { | 219 | if(this.resizeCanvases) { |
@@ -490,8 +517,8 @@ exports.Stage = Montage.create(Component, { | |||
490 | this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; | 517 | this._scrollLeft = this.application.ninja.currentDocument.model.views.design.document.body.scrollLeft; |
491 | this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; | 518 | this._scrollTop = this.application.ninja.currentDocument.model.views.design.document.body.scrollTop; |
492 | 519 | ||
493 | this.userContentLeft = -this._scrollLeft; | 520 | this.userContentLeft = this._documentOffsetLeft - this._scrollLeft; |
494 | this.userContentTop = -this._scrollTop; | 521 | this.userContentTop = this._documentOffsetTop - this._scrollTop; |
495 | 522 | ||
496 | // TODO - scroll events are not dependable. We may need to use a timer to simulate | 523 | // TODO - scroll events are not dependable. We may need to use a timer to simulate |
497 | // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values | 524 | // scrollBegin and scrollEnd. For now, the Pan Tool will keep track of the stage's scroll values |