Discover top-quality rehabilitation knee products designed to support your recovery journey effectively. Our range includes braces, supports, and accessories crafted for stability and comfort during rehabilitation. Explore innovative solutions to aid mobility and strength, ensuring optimal support post-injury or surgery. Regain confidence in movement with Dr. Odin's rehabilitation knee solutions.
document.addEventListener('DOMContentLoaded', function() {
// Wait a bit for everything to load
setTimeout(function() {
initStickyGallery();
}, 100);
});
function initStickyGallery() {
const gallery = document.querySelector('.product-gallery');
const productMain = document.querySelector('.product-main');
// If elements don't exist, exit
if (!gallery || !productMain) return;
// Track if sticky is active
let isStickyActive = true;
function checkSticky() {
// Only run on desktop
if (window.innerWidth < 1024) {
if (isStickyActive) {
gallery.style.position = '';
gallery.classList.remove('sticky-ended');
isStickyActive = false;
}
return;
}
// Get positions
const galleryRect = gallery.getBoundingClientRect();
const productMainRect = productMain.getBoundingClientRect();
const footer = document.querySelector('footer') || document.querySelector('.site-footer');
const footerRect = footer ? footer.getBoundingClientRect() : null;
// Get the bottom of the right column content
const rightColumnBottom = productMainRect.bottom;
const viewportHeight = window.innerHeight;
// Also check if gallery would hit the footer
let galleryWouldHitFooter = false;
if (footerRect) {
const galleryBottomRelative = galleryRect.top + gallery.offsetHeight;
if (galleryBottomRelative >= footerRect.top - 50) {
galleryWouldHitFooter = true;
}
}
// Condition to end sticky:
// Either right column content is fully scrolled past viewport
// OR gallery would overlap with footer
if (rightColumnBottom <= viewportHeight + 100 || galleryWouldHitFooter) {
if (isStickyActive) {
gallery.style.position = 'relative';
gallery.classList.add('sticky-ended');
isStickyActive = false;
}
} else {
if (!isStickyActive) {
gallery.style.position = 'sticky';
gallery.style.top = '30px';
gallery.classList.remove('sticky-ended');
isStickyActive = true;
}
}
}
// Run on scroll and resize
window.addEventListener('scroll', checkSticky);
window.addEventListener('resize', checkSticky);
// Initial check
checkSticky();
}