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

274
Views
How to do something when window on needed heigth

I have some HTML code

<div class="mission" id="mission_block">
            <div class="mission__img">
                <img src="img/phone90.png" alt="">
            </div>
            <div class="mission__text">
                <h1>Our mission and vision</h1>
                <p>While technology is our sweet spot, we’ve developed our vision alongside
                    our customers to ensure your everyday problems are solved through simplistic tools. And as your
                    business grows, we’ll grow right alongside with you. </p>
            </div>
        </div>

I need animate this blocks when window will be on the middle of block mission. How can I create trigger for this?

I already have such JS code:

((window, document) => {
   window.onload = () => {
      const missionBlock = document.getElementById('mission_block');

      const sizes = missionBlock.getBoundingClientRect();

      const {height, top} = sizes
      const scrollTriggerHeigth = top + height / 2

   }
})(window, document, undefined)
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You could do this easily with Intersection Observer API.

E.g.

const missionBlock = document.getElementById("mission_block");

let observer = new IntersectionObserver(
  (entries) => {
    // Take the first entry
    const entry = entries[0];

    if (entry.isIntersecting) {
      // do here whatever you need to do
      console.log("instersecting", entry);
      doWhatever();
    }
  },
  { threshold: 0.5 }
);

observer.observe(missionBlock);
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!