Okay, to do this with native JS you have to take a few steps.
In order will:
- Tie Event Headset to mousedown
- Tie event headset to Mousemove
- make bar have position: Absolute
- give top position equal to mouse position
- calculate the coordinate of the corner of the
ul
- calculate the difference between that coordinate and the mouse position
- give the height of the div that difference.
In code it can be like this:
window.onload = addListeners;
function addListeners(){
document.querySelector('.resize').addEventListener('mousedown', mouseDown, false);
window.addEventListener('mouseup', mouseUp, false);
}
function mouseUp(){
window.removeEventListener('mousemove', divMove, true);
}
function mouseDown(e){
window.addEventListener('mousemove', divMove, true);
}
function divMove(e){
var div = document.querySelector('.resize');
div.style.position = 'absolute';
div.style.top = e.clientY + 'px';
var altura = div.previousElementSibling.getBoundingClientRect().top;
div.previousElementSibling.style.height = (e.clientY - altura) + 'px';
}
Perfect friend, could only clarify me what is the receiver?
– waghcwb
@Wag headset = "headset" = System
– bfavaretto
Thanks friend. It will be of great use
– waghcwb