Barba: Current container position on back button click

Created on 2 Sep 2020  Â·  6Comments  Â·  Source: barbajs/barba

Hi!

When I click on the back button of the browser, the scroll top position of the current container change (randomly?), and I can't find why.

I'm using a very simple transition to test it :

.fade-leave
.fade-once-to
.fade-enter-to
  opacity 1

.fade-enter,
.fade-once,
.fade-leave-to
  opacity 0

.fade-leave-active,
.fade-once-active,
.fade-enter-active
  transition opacity 200ms ease

Any idea ?
Thanks!

duplicate question

All 6 comments

Hi @theamnesic,

Are you talking about @barba/css plugin issue?
Thanks

Hi Xavier,

I have the same behavior without @barba/css.
This scroll top move only appear on the back button.

Here a screenshot, you can see the container
Look like barba keep the previous scrollTop position even if we set to 0 at enter.

— G

Ho ok!

I wasn't figure it out ^^

Can you check this comment and tell me if it works for you?
https://github.com/barbajs/barba/issues/537#issuecomment-658160045.

Thanks!

It works!

Just put this on enter hook :

if ('scrollRestoration' in history) {
  history.scrollRestoration = 'manual';
}

Merci Xavier !

De rien @theamnesic :wink:
Happy coding with Barba!

I am closing the issue.

Duplicate of #537.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

iamtompickering picture iamtompickering  Â·  3Comments

S1SYPHOS picture S1SYPHOS  Â·  3Comments

3oax picture 3oax  Â·  4Comments

pierredarrieutort picture pierredarrieutort  Â·  3Comments

hosxes picture hosxes  Â·  3Comments