Created
September 17, 2015 04:10
-
-
Save orellabac/9b7d9e6d0131256abb3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrange(windows) | |
{ | |
var i = 0; | |
var maxHeight = 0; | |
var currentX = 0; | |
var currentY = 0; | |
var maxWidth = window.innerWidth; | |
var padding = 10; | |
var paddingY = 30; | |
for (i=0;i<windows.length;i++) | |
{ | |
var currentWindow = $(windows[i]); | |
//var left = Number.parseInt(currentWindow.css("left")); | |
//var top = Number.parseInt( currentWindow.css("top")); | |
var height = Number.parseInt( currentWindow.css("height")); | |
var width = Number.parseInt( currentWindow.css("width")); | |
currentWindow.css("left",currentX + "px"); | |
currentWindow.css("top",currentY +"px"); | |
console.log("maxH" + maxHeight); | |
console.log("H" + height); | |
maxHeight = Math.max(maxHeight, height); | |
//La coloco si se puede | |
if (currentX + width > maxWidth) | |
{ | |
currentX = 0; | |
currentY = currentY + maxHeight + paddingY; | |
maxHeight = 0; | |
} | |
else { | |
currentX = currentX + width + padding; | |
} | |
console.log("Left Sera" + currentX + "px"); | |
console.log("Top Sera" + currentY + "px"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment