I wanna impl android wheel time picker in js
I find this demo: https://demo.mobiscroll.com/jquery/datetime/gregorian-jalali-hijri#
see my gif, the demo scroll view scrollTop always 0, but in my draft code, scrollTop cannot scroll up, so when scrollTop 0, what's mechanism in this demo to scroll up
Whenever a user scrolls, it affects an elements scrolling box. windows.scrollTo() will affect the scrolling box of the uppermost containing block. This affects people call it scrolling the window or document.
I find the tmp solution
when scrollTop 0, scroll view event "scroll" doesn't trigger, event "wheel"(mouse wheel scroll up) and "touchmove"(mobile drag to scroll up) still work
following is my code using event "wheel"
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<!--mobile friendly-->
<meta name="viewport" content="width=device-width, user-scalable=yes">
<style>
.c0 {
height: 500px;
display: flex;
justify-content: center;
align-items: center;
background-color: lightblue;
}
.c {
top: 50%;
width: 100%;
height: 300px;
border: 5px solid black;
overflow-y: auto;
}
.inner {
background-color: pink;
margin-top: 0px;
width: 100%;
user-select: none;
height: 1000px;
}
</style>
</head>
<body>
<div class="c0">
<div class="c">
<div class="inner">inner</div>
</div>
</div>
<script type="module">
var c = document.querySelector(".c")
var inner = document.querySelector(".inner")
var startY
inner.addEventListener("wheel", (ev) => {
console.log("wheel")
inner.style.marginTop = `${inner.offsetTop + ev.deltaY}px`
})
</script>
</body>
</html>