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

232
Views
Change position fixed of div if scroll

I tried to fix a div after scroll on vuejs; My code like this :

...
async created() {
    window.addEventListener('scroll', this.calendarScroll);
}
methods: {
    calendarScroll() {
    console.log('Scroll');
    const dateHeader = document.querySelector('.dates-header');
    if (dateHeader) {
      if (window.scrollTop() >= 200) {
        dateHeader.style.top = 0;
        dateHeader.style.position = 'fixed';
      }
    }
  },
}

the error is : Calendar.vue?404a:681 Uncaught TypeError: window.scrollTop is not a function

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can add scrollTo to the Element prototype before you mount:

Element.prototype.scrollTo = () => {} 

All Elements created after you add this code will have the scrollTo method. For more detail, you can check this: https://github.com/vuejs/vue-test-utils/issues/319#issuecomment-354667621

about 4 years ago · Juan Pablo Isaza Report

0

You can just jquery scroll

$(window).scroll(function() {
   this.calendarScroll();
});
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!