diff --git a/index.html b/index.html index 7ed6e2d..7d91364 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@

windows.open(Welcome)

-
+

10 Sept 21

diff --git a/scripts/App.js b/scripts/App.js index a8278fc..0a63b18 100644 --- a/scripts/App.js +++ b/scripts/App.js @@ -1,14 +1,13 @@ // TODO // glyphs - // random position // what buttons where // colophone // a bit more interface - // DONE // Open window icon (on background 'desktop') // Close window button (on 'window' itself) + // random position let corpi = { 0: { @@ -37,7 +36,8 @@ $(document).ready(function(){ // Generate divs Object.values(corpi).forEach(corpus => { - $('#boxes' ).append(` + + $('#dragZone' ).append(`

${corpus['title']}

${corpus['content']}

@@ -49,7 +49,6 @@ $(document).ready(function(){ // Start mouse UI const dragResize = new DragResizeClose(); - }); class DragResizeClose { constructor() { @@ -98,16 +97,36 @@ class DragResizeClose { $( ".draggable" ).each(function() { let rw = getRndInteger((getWidth())/2-500,(getWidth())/2) //let rh = getRndInteger(heightDrag-200, heightDrag) - $( this ).css("width",rw); - $( this ).css("height", 'auto'); + + //setDimension + $(this).css("width",rw); + $(this).css("height", 'auto'); + + //setPosition + let w = window.innerWidth; + let h = window.innerHeight; + + if (this.id != 'program'){ + let wBox = $(this).css('width'); + let hBox = $(this).css('height'); + let rX = randomCorrected(h, hBox); + let rY = randomCorrected(w, wBox); + $(this).css("top", rX); + $(this).css("left", rY); + } else { + $(this).css("top", '20px'); + $(this).css("right", '20px'); + } + }); } setZindex() { - $('#dragZone div').click(() => { // Setup z-index handler + let zIndex = 3; + $('#dragZone div').mousedown(function() { // Setup z-index handler $(this).addClass('top').removeClass('bottom'); $(this).siblings().removeClass('top').addClass('bottom'); - $(this).css("z-index", this.zIndex++); + $(this).css("z-index", zIndex++); }); } @@ -133,3 +152,7 @@ class DragResizeClose { } } +function randomCorrected(sideWindow, sideBox){ + var corrected = sideWindow - parseInt(sideBox); + return Math.floor(Math.random() * corrected) +} \ No newline at end of file