# Help with Issue in Firefox on page reload

**URL:** <https://forum.freecodecamp.org/t/help-with-issue-in-firefox-on-page-reload/309364>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [August 26, 2019, 5:37pm UTC](https://forum.freecodecamp.org/t/help-with-issue-in-firefox-on-page-reload/309364 "2019-08-26T17:37:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Xevoxe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/xevoxe/32/102936_2.png) [@Xevoxe](https://forum.freecodecamp.org/u/Xevoxe)\
**Post date:** [August 26, 2019, 5:37pm UTC](https://forum.freecodecamp.org/t/help-with-issue-in-firefox-on-page-reload/309364/1 "2019-08-26T17:37:35Z")

</div>

The page loads fine the first time however upon refresh the stickyPos comes back incorrectly and causes the image to stick prematurely. After a few refreshes it will fix itself again until it refreshes again. Im not sure what might be the cause of this as it works as expected in the other browsers including mobile.

[Website](https://xevoxe.github.io/Yami)

```javascript
const stickyElement = (pos,element) =>{
    let stickyPos = document.getElementById(element).offsetTop - document.documentElement.clientHeight * pos;
    let elmt = document.getElementById(element);
    return function () {
        let scrollPos = window.pageYOffset;
        // console.log(scrollPos);
        // console.log(`Sticky = ${stickyPos}`)
        if(scrollPos >= stickyPos){
            elmt.classList.add("sticky");
        }else{
            elmt.classList.remove("sticky");
        }
    }
}

css:
.sticky {
      position:fixed;
      top: 50vh;
    }

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 25, 2021, 12:19pm UTC](https://forum.freecodecamp.org/t/help-with-issue-in-firefox-on-page-reload/309364/2 "2021-01-25T12:19:33Z")

</div>


