-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
25 lines (21 loc) · 914 Bytes
/
Copy pathmain.js
File metadata and controls
25 lines (21 loc) · 914 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function manage_split() {
const container = document.getElementById('main-container');
const center = document.getElementById('center');
const left = document.getElementById('left');
let moving = false;
document.addEventListener('mouseup', _ => {
moving = false;
document.body.style.cursor = 'default';
});
center.addEventListener('mousedown', _ => moving = true);
document.addEventListener('mousemove', e => {
if(!moving) return;
document.getSelection().empty();//para que no se seleccione el texto cuando nos movemos rápido.
document.body.style.cursor = 'ew-resize';
const rec = container.getBoundingClientRect();
const dx = Math.max(100, e.clientX - rec.x);
const newLeftWidth = (dx / rec.width) * 100
left.style.width = newLeftWidth + '%';
});
}
window.addEventListener('load', manage_split);