Heyy, I'm really new to web development and more specifically using JavaScript and Jquery. I would like to know how to increase the speed at which my Sidebar scrolls down along with the user.
Jquery Code of the sidebar scrolling effect:
$(function() {
var $sidebar = $(".aside"),
$window = $(window),
offset = $sidebar.offset(),
topPadding = 100;
$window.scroll(function() {
if ($window.scrollTop() > offset.top) {
$sidebar.stop().animate({
marginTop: $window.scrollTop() - offset.top + topPadding
});
} else {
$sidebar.stop().animate({
marginTop: 60
});
}
});
});
CSS Code of my Sidebar:
.aside {
display:inline-block;
float:right;
background: red;
width: 330px;
min-height: 40vw;
margin-right: 130px;
margin-top: 60px;
padding: 0 20px;
box-shadow: inset 0 -1px 0 rgb( 79 131 170 / 20%), 0 0 30px rgb(0 0 0 / 7%);
border-radius: 5px;
}