Spaces:
Running
on
L40S
Running
on
L40S
File size: 971 Bytes
4450790 |
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 26 27 28 29 30 31 32 33 34 35 |
/**
* File: splitPane.js
* Project: comfy_mtb
* Author: Mel Massadian
*
* Copyright (c) 2023 Mel Massadian
*
*/
function initSplitPane(vertical) {
let resizer = document.getElementById('resizer')
let left = document.getElementById('leftPane')
let right = document.getElementById('rightPane')
resizer.addEventListener('mousedown', function (e) {
document.addEventListener('mousemove', onMouseMove)
document.addEventListener('mouseup', function () {
document.removeEventListener('mousemove', onMouseMove)
})
})
const onMouseMove = (e) => {
if (vertical) {
let leftWidth = e.clientX
let rightWidth = window.innerWidth - e.clientX
left.style.width = leftWidth + 'px'
right.style.width = rightWidth + 'px'
} else {
let topHeight = e.clientY
let bottomHeight = window.innerHeight - e.clientY
left.style.height = topHeight + 'px'
right.style.height = bottomHeight + 'px'
}
}
}
|