diff --git a/index.html b/index.html index 7ed6e2d..7d91364 100644 --- a/index.html +++ b/index.html @@ -21,7 +21,7 @@
${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