πCustom Widget (HTML widget)
Last updated
Last updated
.gh-sidebar-custom-widget {
position: sticky;
top: 100px;
animation: fadeIn 1s ease-in-out;
transition: top 0.45s ease;
}
.gh-sidebar-custom-widget.with-big-header {
top: 180px;
}
.gh-sidebar-custom-widget.moved {
top: 28px;
}
.gh-sidebar-custom-widget.inside-post {
padding-bottom: 104px;
}const moveWidget = () => {
const widget = document.querySelector('#sidebar-custom-widget');
let lastScrollTop = 0;
const widgetScrollHandler = () => {
const scrollTop = window.scrollY;
const windowWidth = window.innerWidth;
if (windowWidth > 1100) {
if (scrollTop > 200) {
if (scrollTop > lastScrollTop) {
widget.classList.add('moved');
} else {
widget.classList.remove('moved');
}
}
lastScrollTop = scrollTop;
}
};
if (widget) {
window.addEventListener('scroll', widgetScrollHandler);
}
};
moveWidget();