mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 01:32:36 +02:00
chat: improve window sizing
This commit is contained in:
parent
871f13ceb1
commit
87dd81581c
1 changed files with 10 additions and 10 deletions
|
@ -184,17 +184,18 @@ Maintain a friendly, patient, supportive tone. Prioritize the user's learning an
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
isResizing = true;
|
isResizing = true;
|
||||||
let startX = e.pageX;
|
let startX = e.pageX;
|
||||||
|
let initialLeftColWidth = leftCol.offsetWidth; // Capture the initial width when resizing starts
|
||||||
|
|
||||||
function handleMouseMove(e) {
|
function handleMouseMove(e) {
|
||||||
if (!isResizing) return;
|
if (!isResizing) return;
|
||||||
const editorRowWidth = editorRow.offsetWidth; // Get the total width of the editor row
|
const editorRowWidth = editorRow.offsetWidth; // Get the total width of the editor row
|
||||||
let moveX = e.pageX - startX;
|
let moveX = e.pageX - startX;
|
||||||
let leftColWidth = leftCol.offsetWidth + moveX;
|
let leftColWidth = initialLeftColWidth + moveX; // Use the initial width for relative adjustments
|
||||||
|
|
||||||
// Convert to percentage
|
// Convert to percentage
|
||||||
let leftColPercentage = (leftColWidth / editorRowWidth) * 100;
|
let leftColPercentage = (leftColWidth / editorRowWidth) * 100;
|
||||||
let rightColPercentage = 100 - leftColPercentage;
|
let rightColPercentage = 100 - leftColPercentage;
|
||||||
|
|
||||||
// Check and enforce the minimum and maximum widths
|
// Check and enforce the minimum and maximum widths
|
||||||
if (rightColPercentage < 20) { // Minimum 20% for right column
|
if (rightColPercentage < 20) { // Minimum 20% for right column
|
||||||
rightColPercentage = 20;
|
rightColPercentage = 20;
|
||||||
|
@ -203,21 +204,20 @@ Maintain a friendly, patient, supportive tone. Prioritize the user's learning an
|
||||||
rightColPercentage = 80;
|
rightColPercentage = 80;
|
||||||
leftColPercentage = 20;
|
leftColPercentage = 20;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Apply the new widths
|
// Apply the new widths
|
||||||
leftCol.style.width = `${leftColPercentage}%`;
|
leftCol.style.width = `${leftColPercentage}%`;
|
||||||
rightCol.style.width = `${rightColPercentage}%`;
|
rightCol.style.width = `${rightColPercentage}%`;
|
||||||
localStorage.setItem('leftColPct', leftCol.style.width)
|
localStorage.setItem('leftColPct', `${leftColPercentage}%`);
|
||||||
localStorage.setItem('rightColPct', rightCol.style.width)
|
localStorage.setItem('rightColPct', `${rightColPercentage}%`);
|
||||||
startX = e.pageX;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMouseUp() {
|
function handleMouseUp() {
|
||||||
window.removeEventListener('mousemove', handleMouseMove);
|
window.removeEventListener('mousemove', handleMouseMove);
|
||||||
window.removeEventListener('mouseup', handleMouseUp);
|
window.removeEventListener('mouseup', handleMouseUp);
|
||||||
isResizing = false;
|
isResizing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
window.addEventListener('mousemove', handleMouseMove);
|
window.addEventListener('mousemove', handleMouseMove);
|
||||||
window.addEventListener('mouseup', handleMouseUp);
|
window.addEventListener('mouseup', handleMouseUp);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue