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

176
Views
Barba.js : scrollRestoration and Wordpress issue

I'm trying to put somme animation between my home and my single page using barba.js (if something works better with wordpress let me know), Actually when I click to my post, the single page is scrolled as the other page was, it restore the scroll even When I put

barba.hooks.before(() => {
  if (history.scrollRestoration) {
    history.scrollRestoration = 'manual';
  }
});

barba.init({
  debug: true,
  transitions: [{
    name: 'projet-transition',
    from: {
      namespace: [
        'home'
      ]
    },
    to: {
      namespace: [
        'projet'
      ]
    },
    enter(data) {
        console.log(data)
    },
    leave(data) {
      console.log(data)
    },
  }]
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To reset the scroll position when navigating through links, you can do this:

barba.hooks.enter(() => {
    window.scrollTo(0, 0);
});

About scrollRestoration

History.scrollRestoration affects back and forward history navigation. If you need to restore scroll position when navigating backwards or forwards, check out this barba.js github issue. If not, I think it would be better if you don't set scrollRestoration to manual in the before hook, which runs on every page transition. You can place it outside barba hooks or in the beforeOnce hook.

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!