If you want an even closer reproduction of high-end sites like Gucci, instead of a hard toggle at 150px, calculate the scale dynamically based on scroll distance:
window.addEventListener('scroll', () => {
const nav = document.getElementById('stickyNav');
const scrollY = window.scrollY;
const maxScroll = 200; // Distance over which the transition completes
const progress = Math.min(scrollY / maxScroll, 1);
// Interpolate position and scale dynamically
if (progress > 0) {
nav.classList.add('isSticky');
} else {
nav.classList.remove('isSticky');
}
}, { passive: true });
Give this CSS transition tweak a shot - using scale() instead of changing font-size directly should solve the layout jump completely!