diff options
| -rw-r--r-- | js/app.js | 2 | ||||
| -rw-r--r-- | js/matrix.js | 22 | ||||
| -rw-r--r-- | js/ui/controls.js | 19 |
3 files changed, 23 insertions, 20 deletions
@@ -32,7 +32,7 @@ function build () { brush.build() // controls.grid.use() - controls.rotate.refresh() + canvas.resize_rapper() } function bind () { canvas.bind() diff --git a/js/matrix.js b/js/matrix.js index 90ff7fc..a6064ca 100644 --- a/js/matrix.js +++ b/js/matrix.js @@ -182,8 +182,28 @@ Matrix.prototype.resize = function(w,h){ this.h = h this.bind && this.bind() - if (this.rotated) { controls.rotate.refresh(this.rotated) } + this.rapper && this.resize_rapper() } +Matrix.prototype.resize_rapper = function(){ + if (this.rotated) { + this.rapper.parentNode.classList.add("rotated") + this.rapper.parentNode.style.height = (this.rapper.firstChild.offsetWidth+20) + "px" + this.rapper.parentNode.style.width = (this.rapper.offsetHeight+20) + "px" + this.rapper.style.top = ((this.rapper.offsetWidth+20)/2) + "px" + // this.rapper.style.left = ((canvas_rapper.offsetHeight+20)/2) + "px" + } + else { + var width = this.aa[0][0].span.offsetWidth * this.aa[0].length + console.log(width, this.rapper.firstChild.offsetWidth) + this.rapper.parentNode.classList.remove("rotated") + this.rapper.parentNode.style.height = "" + this.rapper.style.width = + this.rapper.parentNode.style.width = (width) + "px" + this.rapper.style.top = "" + // canvas_rapper.style.left = "auto" + } +} + // diff --git a/js/ui/controls.js b/js/ui/controls.js index 50eea73..c5641c6 100644 --- a/js/ui/controls.js +++ b/js/ui/controls.js @@ -199,24 +199,7 @@ var controls = (function(){ controls.rotate = new BlurredCheckbox (rotate_checkbox) controls.rotate.use = function(state){ canvas.rotated = typeof state == "boolean" ? state : ! canvas.rotated - controls.rotate.refresh() - } - controls.rotate.refresh = function(){ - if (canvas.rotated) { - canvas_rapper.parentNode.classList.add("rotated") - canvas_rapper.parentNode.style.height = (canvas_rapper.firstChild.offsetWidth+20) + "px" - canvas_rapper.parentNode.style.width = (canvas_rapper.offsetHeight+20) + "px" - canvas_rapper.style.top = ((canvas_rapper.offsetWidth+20)/2) + "px" - // canvas_rapper.style.left = ((canvas_rapper.offsetHeight+20)/2) + "px" - } - else { - canvas_rapper.parentNode.classList.remove("rotated") - canvas_rapper.parentNode.style.height = "" - canvas_rapper.style.width = - canvas_rapper.parentNode.style.width = (canvas_rapper.firstChild.offsetWidth+20) + "px" - canvas_rapper.style.top = "" - // canvas_rapper.style.left = "auto" - } + canvas.resize_rapper() this.update(canvas.rotated) } |
