Experience the joy of hearing your baby's heartbeat with Dr. Odin's Fetal Doppler. Our innovative device offers expectant parents peace of mind by providing clear, reliable fetal heart rate monitoring at home. Stay connected to your baby's well-being effortlessly with our user-friendly and medically trusted Fetal Doppler.
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();
}