Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

waypoints element jumpy on iOS & Safari #611

Open
kaspar-allenbach opened this issue Dec 30, 2019 · 0 comments
Open

waypoints element jumpy on iOS & Safari #611

kaspar-allenbach opened this issue Dec 30, 2019 · 0 comments

Comments

@kaspar-allenbach
Copy link

I have a sticky header which receives a class as soon as the user scrolls past another element.

On safari and iOS it is so jumpy and jittery its unusable.
I read that position: sticky and the waypoint's plugin don't go well together, so I separated them that the sticky wrapper doesn't act as a waypoint listener.

html:

<div class="siteNavi"> 
  <div class="triggerWrapper"> 
      <div class="layoutHolder"> 
        <!-- The navigation links  -->
    </div>
  </div>
</div>

<div class="content">
    <!-- All content of the website.
     If I scroll past here, waypoints.js adds a class to the triggerWrapper -->
</div>

My js code:

if ($(".siteNavi").length) {
    var nailElement = 'content';
    var triggerElement = 'triggerWrapper';
    var waypoint = new Waypoint({
        element: document.getElementsByClassName(nailElement),
        handler: function (direction) {
            if (direction === "down") {
                $("." + triggerElement).addClass("triggered");
            }
            if (direction === "up") {
                $("." + triggerElement).removeClass("triggered");
            }
            console.log("Basic waypoint triggered" + "Direction: " + direction);
        },
        offset: 0
    });
}

css

.content {
    position: relative;
}
.siteNavi {
    position: sticky;
    position: -webkit-sticky;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    top: 0;
    width: 100%;
    height: 50px;
    background-color: #27292b;
    z-index: 1000;
}

Can I optimize this in any way? The class .triggered is added to .triggerWrapper which has no css directives, so I think position:sticky is out of the equation, no?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant