I have a layout with a large sidebar and small content, where the "Fixed part" refers to sticky positioning.
I'm attempting to achieve this using scrollTop, but the sidebar is causing some issues like this:
The code should only be executed when the height of the main content is less than the sidebar content height.
This is the code from my latest attempt:
function sidebarParallax(expertStatisticsHeight) {
var sidebar = $('aside.site-aside');
var main = $('main.site-content');
var footer = $('footer');
var c = 1;
sidebar.css({
position: 'absolute',
right: 0,
width: $(document).width() - main.width(),
});
if ((expertStatisticsHeight + $banner.height()) > main.height()) {
var speed = c - (main.height() / sidebar.height());
sidebar.css('transform', 'translateY(' + -speed + 'px)');
} else {
sidebar.removeAttr('style');
}
}
How can I ensure that when I scroll to the bottom, the bottom of the sidebar aligns with the bottom of the content?
Thank you in advance!