fix random position height to not overlap title

Tancre 3 years ago
parent 7c0ddd775b
commit 72db5bef40

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