Window dragging handling

This commit is contained in:
AMay 2026-05-13 19:23:22 -05:00
parent 92d098c8ca
commit d378f76ee2
2 changed files with 17 additions and 7 deletions

View File

@ -15,7 +15,6 @@
<li>A Notepad</li>
<li>Or even a File Explorer!</li>
</ul>
<div class="filler" style="min-height:100px;"></div>
</div>
<div class="status-bar">
<p class="status-bar-field">Press F1 for help</p>
@ -34,7 +33,6 @@
<li>A Notepad</li>
<li>Or even a File Explorer!</li>
</ul>
<div class="filler" style="min-height:100px;"></div>
</div>
<div class="status-bar">
<p class="status-bar-field">Press F1 for help</p>
@ -53,7 +51,6 @@
<li>A Notepad</li>
<li>Or even a File Explorer!</li>
</ul>
<div class="filler" style="min-height:100px;"></div>
</div>
<div class="status-bar">
<p class="status-bar-field">Press F1 for help</p>

View File

@ -41,7 +41,15 @@ function OpenWindow(windowName){
newWindow.style.minWidth=256;
newWindow.style.width=newWindow.style.minWidth;
newWindow.style.zIndex=windowDepth++
newWindow.style.minHeight=newWindow.getBoundingClientRect().height;
let body=newWindow.getElementsByClassName("window-body")[0]
if(body){
var filler=document.createElement("div")
body.appendChild(filler)
filler.classList.add("filler")
filler.style.minHeight=100;
}
newWindow.style.minHeight=newWindow.getBoundingClientRect().height+filler.style.minHeight;
newWindow.style.height=newWindow.style.minHeight;
}
function addListeners(){
@ -94,6 +102,7 @@ function mouseDown(e){
offY= e.clientY-parseInt(div.offsetTop);
offX= e.clientX-parseInt(div.offsetLeft);
rightSideX=parseInt(div.offsetLeft)+parseInt(div.style.width);
let filler=div.getElementsByClassName("filler")[0]
bottomSideY=parseInt(div.offsetTop)+parseInt(div.style.height);
window.addEventListener('mousemove', divMove, true);
window.targetWindow=div;
@ -108,21 +117,25 @@ function divMove(e){
div.style.top = (e.clientY-offY) + 'px';
div.style.left = (e.clientX-offX) + 'px';
}else{
let prevPosX=parseInt(div.style.left);
let prevPosY=parseInt(div.style.top);
if(side&Side.RIGHT)div.style.width=e.clientX-parseInt(div.offsetLeft);
if(side&Side.LEFT){
div.style.left=(e.clientX-offX)+'px';
div.style.width=rightSideX-parseInt(div.style.left);
div.style.width=parseInt(div.style.width)-(parseInt(div.style.left)-prevPosX)
}
if(side&Side.BOTTOM){
div.style.height=e.clientY-parseInt(div.offsetTop);
}
if(side&Side.TOP){
div.style.top=(e.clientY-offY)+'px';
div.style.height=bottomSideY-parseInt(div.style.top);
div.style.height=parseInt(div.style.height)-(parseInt(div.style.top)-prevPosY)
}
for(let filler of div.getElementsByClassName("filler")){
console.log(filler)
filler.style.height=parseInt(div.style.height)-parseInt(div.style.minHeight)+parseInt(filler.style.minHeight);
}
div.style.width=Math.max(parseInt(div.style.minWidth),parseInt(div.style.width));
div.style.height=Math.max(parseInt(div.style.minHeight),parseInt(div.style.height));
}
}