I want To create vertical select like image below, anyone can help me?
I've tried to make one but no the result is not what I want, the active class is not in the middle between the arrows when scrolled.
const div = document.querySelectorAll("#menulist");
const atag = document.querySelectorAll("#list");
var curLen = 0;
let len = atag.length;
function activeMenu(){
debugger
if(event.wheelDelta > 0){
if(curLen > 0){
curLen --;
}
atag.forEach(ltx => ltx.classList.remove("active"));
atag[curLen].classList.add("active");
} else {
if((len - curLen) > 1){
curLen ++;
}
atag.forEach(ltx => ltx.classList.remove("active"));
atag[curLen].classList.add("active");
}
}
window.addEventListener('wheel', activeMenu);
.menuBox {
margin: 0 auto;
width:100%;
margin: 23em 0 0 0;
}
.vertical-menu {
display: flex;
float:left;
height: 450px;
}
.vertical-menu:after {
display: block;
content: '';
clear: both;
}
.vertical-menu .list{
margin-top:-100px;
text-align:center;
display:inline-block;
font-size:var(--small-font-size);
overflow-y: auto;
width:100%;
/* scroll-snap-type: y mandatory; */
-ms-overflow-style: none;
}
.vertical-menu .list a.active {
background-color: #fff;
color:#000;
font-weight: bold;
font-size:var(--menulist-font-size);
}
.vertical-menu .list::-webkit-scrollbar{ display:none; }
.vertical-menu .left{
display:inline-block;
text-align:center;
font-size:50px;
widht:10%;
}
.vertical-menu .right{
display:inline-block;
text-align:center;
font-size:50px;
widht:10%;
}
.vertical-menu a {
font-family: fantasy;
background-color: #fff;
color: #bbbbbb;
display: block;
padding: 12px;
text-decoration: none;
}
.vertical-menu a:hover {
/* background-color: #fff;
color:#000;
font-weight: bold; */
}
.vertical-menu a.active {
background-color: #fff;
color:#000;
font-weight: bold;
font-size:50px;
}
.vertical-icon {
width:40%;
text-align:center;
align-items:center;
display: flex;
justify-content:center;
margin: 0 0 0 0;
}
<div class="menuBox">
<div class="vertical-menu align-self-center">
<div class="vertical-menu left"><a href="#"><</a></div>
<div id="menulist" class="vertical-menu list" style="display:inline !important;">
<a id="list" href="#" >Home</a>
<a id="list" href="#" >TPHO Receive</a>
<a id="list" href="#" >PO Completion</a>
<a id="list" href="#" >HQ Revision</a>
<a id="list" href="#" >Pre-BOM</a>
<a id="list" href="#" >CR2 BOM</a>
<a id="list" href="#" >Final BOM</a>
<a id="list" href="#" >Upper Mold</a>
<a id="list" href="#" >Bottom Mold</a>
</div>
<div class="vertical-menu right"><a href="#">></ion-icon></a></div>
</div>
</div>
actually i want to make this component in vue but i want to try it first with css and js then i will customize it in vue. but my css skills are bad.
or is there a select library like the view I want above? it looks like it will be easier
