fix random position height to not overlap title

master
Tancre 3 years ago
parent 7c0ddd775b
commit 72db5bef40

@ -52,7 +52,6 @@ $(document).ready(function(){
});
class DragResizeClose {
constructor() {
this.zIndex = 3;
this.drag();
this.setDraggables();
this.setZindex();
@ -61,9 +60,7 @@ class DragResizeClose {
}
drag() {
$('.draggable').draggable({ containment: "window" }, { // Setup dragging and containment
start: (event, ui) => $(this).css("z-index", this.zIndex++) // Initialize z-index
});
$('.draggable').draggable({ containment: "window" });
}
setDraggables() {
@ -78,22 +75,6 @@ class DragResizeClose {
);
}
//let widthDrag = (getWidth())/2;
// function getHeight() {
// return Math.max(
// document.body.scrollHeight,
// document.documentElement.scrollHeight,
// document.body.offsetHeight,
// document.documentElement.offsetHeight,
// document.documentElement.clientHeight
// );
// }
// let heightDrag = (getHeight())/2;
const getRndInteger = (min, max) => Math.floor(Math.random() * (max - min + 1) ) + min;
$( ".draggable" ).each(function() {
let rw = getRndInteger((getWidth())/2-500,(getWidth())/2)
//let rh = getRndInteger(heightDrag-200, heightDrag)
@ -109,8 +90,8 @@ class DragResizeClose {
if (this.id != 'program'){
let wBox = $(this).css('width');
let hBox = $(this).css('height');
let rX = randomCorrected(h, hBox);
let rY = randomCorrected(w, wBox);
let rX = randomCorrectedHeight(h, hBox);
let rY = randomCorrectedWidth(w, wBox);
$(this).css("top", rX);
$(this).css("left", rY);
} else {
@ -152,7 +133,14 @@ class DragResizeClose {
}
}
function randomCorrected(sideWindow, sideBox){
var corrected = sideWindow - parseInt(sideBox);
const randomCorrectedWidth = (sizeWindow, sizeBox) => {
var corrected = sizeWindow - parseInt(sizeBox);
return Math.floor(Math.random() * corrected)
}
const randomCorrectedHeight = (sizeWindow, sizeBox) => {
var corrected = sizeWindow - parseInt(sizeBox);
return getRndInteger(105, corrected)
}
const getRndInteger = (min, max) => Math.floor(Math.random() * (max - min + 1) ) + min;
Loading…
Cancel
Save