I am currently working on designing a component that allows for adjusting the width proportions of two blocks by using a slider to move them left and right: https://i.sstatic.net/Q85ab.png
Check out the CodePen and demo.
.outer {
display: flex;
flex-direction: row;
}
.block {
height: 200px;
width: -webkit-calc(50% - 5px);
width: -moz-calc(50% - 5px);
width: calc(50% - 5px);
}
.block-1 {
background-color: red;
}
.block-2 {
background-color: green;
}
.slider {
line-height: 100%;
width: 10px;
background-color: #dee2e6;
border: none;
cursor: e-resize;
}
<div id="app">
<div class="outer">
<div class="block block-1">
Block 1
</div>
<div class="slider">
S<br>l<br>i<br>d<br>e<br>r
</div>
<div class="block block-2">
Block 2
</div>
</div>
</div>
I've attempted utilizing the draggable-vue-directive
to change the block widths based on the slider's position.
Unfortunately, it didn't work as expected because the draggable-vue-directive
set the slider to position:fixed
, causing alignment issues with the blocks.
How can I enable horizontal dragging for the .slider
block without using position:fixed
?
What is the correct way to resize Block1
and Block2
when the slider is moved?
Please note: I am not using jQuery