console
let start = 0, during = 60;
const easeIn = function (t, b, c, d) {
return c * (t /= d) * t + b;
}
const run = () => {
let top = easeIn(start, 500, -500, during)
start ++;
document.querySelector('#outer').scrollTop = top;
if (start <= during) {
requestAnimationFrame(run);
}
}
run();
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#outer {
margin: 100px 50px;
background: red;
height: 200px;
width: 500px;
padding: 10px 50px;
overflow: scroll;
}
#inner {
height: 1000px;
width: 500px;
background-color: #d0ffe3;
}
</style>
</head>
<body>
<div id="outer">
<div id="inner"></div>
</div>
</body>
</html>
.class1 {
height: 500px;
width: 500px;
margin: 10px;
background: red;
}
body {
overflow: auto;
}