abouolia / sticky-sidebar

😎 Pure JavaScript tool for making smart and high performance sticky sidebar.
https://abouolia.github.io/sticky-sidebar/
MIT License
2.23k stars 489 forks source link

Sticky sidebar not working if not resize the browser #68

Open blu94 opened 6 years ago

blu94 commented 6 years ago

Sticky sidebar not moving after browser reload, but after i resize the window, the sticky sidebar work

abouolia commented 6 years ago

In my example it works well after reloading the page. Can you give me your config??

mdunbavan commented 6 years ago

Hey just to reach out its doing the same here too with the jQuery version.

tompha commented 6 years ago

I'm experiencing the same issue.

89gsc commented 5 years ago

Same issue I just stuck this after initializing it:

      setTimeout(function () {
        window.dispatchEvent(new Event('resize'));
      }, 500)
sfusato commented 5 years ago

I solved the issue by calling the updateSticky() method right after initializing it.

@gsc89 solution also worked, but the 500ms timeout was visible on the page.

maksnester commented 4 years ago

In my case it was incorrectly scrolled to top after I hit the back button in browser. So this works for me (in SPA)

    window.onpopstate = function() {
      setTimeout(() => {
        window.dispatchEvent(new Event('resize'))
      })
    }