Truly independent web browser
<!DOCTYPE html>
<script src="include.js"></script>
<style>
#scroller {
width: 200px;
height: 200px;
overflow: scroll;
scroll-snap-type: y mandatory;
}
.item {
width: 100%;
height: 200px;
scroll-snap-align: start;
}
#inner {
width: 100px;
height: 100px;
overflow: scroll;
}
#inner > div {
height: 200px;
}
</style>
<div id="scroller">
<div class="item"><div id="inner"><div></div></div></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
<script>
promiseTest(async () => {
const scroller = document.getElementById("scroller");
const inner = document.getElementById("inner");
await animationFrame();
await animationFrame();
// The finger scrolls the inner scroller to its extent, and the momentum of the flick stays with it: a gesture
// keeps the scroller its first step hit, so it does not chain on to the snap container around it.
await scrollSettled(inner, async () => {
await Promise.all([
internals.wheel(50, 50, 0, 50, true, "ongoing"),
internals.wheel(50, 50, 0, 50, true, "ongoing"),
internals.wheel(50, 50, 0, 100, true, "momentum"),
internals.wheel(50, 50, 0, 60, true, "momentum"),
internals.wheel(50, 50, 0, 30, true, "momentum"),
internals.wheel(50, 50, 0, 0, true, "ended"),
]);
});
println(`inner scroll offset: ${inner.scrollLeft},${inner.scrollTop}`);
println(`snap container scroll offset: ${scroller.scrollLeft},${scroller.scrollTop}`);
});
</script>