Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Intersection observer, page is moving

Hello I have a problem with intersection observer. When it applies page has a small lag and content on the page moves a bit what is a problem? How to make it smooth that it just shows and do not nothing with content? I would appreciate any kind of help.

HTML:

<nav class="navbar">
            <img src="/images/Brabant.png" class="navbar__logo">
            <h1 class="navbar__header">Lion of Brabant</h1>
            <div class="navbar__links">
                <a class="navbar__link">about</a>
                <a class="navbar__link">stories</a>
                <a class="navbar__link">contact</a>
            </div>
            
        </nav>
        
        

        <section class="section" id="section--1">
            <div class="main">
                <h1 class="main__header">Luxury close to you</h1>
            </div>
            
        </section>

SCSS:

.navbar {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    color: $light--brown;
    height: 7vh;
    width: 100%;
    background-color: black;
    z-index: 100;
    transition: all .5s;
    @include borderBottomPrimary;

.navbar.sticky {
    transition: all .5s;
    position: fixed;
   
}

JS:

const navbar = document.querySelector('.navbar')
    const main = document.querySelector('.main')
    const navHeight = navbar.getBoundingClientRect().height;
    
    console.log(navHeight)

    const callback = function(entries, observer) {
        const [entry] = entries;
        console.log(entry)
        if (!entry.isIntersecting) {
            console.log('ser')
            navbar.classList.add('sticky')
        } else {
            navbar.classList.remove('sticky') 
        }
    }
    let observer = new IntersectionObserver(callback,{
        root: null,
        threshold: 0,
        rootMargin: `-${navHeight}px`,
      });
      ;

    observer.observe(main);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I solved this problem by absolute positioning of navbar

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!