weddje Posted November 17, 2020 Share Posted November 17, 2020 On the animated header I'm trying to make it appear on scroll down instantly. Even when I'm scrolled down to the bottom of the page. Currently it appears only when scrolling almost to the top of the page. In the example code below I'm trying to have a toggleClass() when the scroll direction is changed. But it's not working. Some advice is much appriciated example code: var scrollUp = document.querySelector('.jwpnavbar--up'); ScrollTrigger.create({ start: 'top -50', end: 99999, markers:true, toggleClass: {className: 'jwpnavbar--scrolled', targets: '.jwpnavbar'} }); ScrollTrigger.create({ start: 'top -300', end: 99999, toggleClass: {className: 'jwpnavbar--up', targets: '.jwpnavbar'}, onUpdate: ({direction}) => { if (direction == -1) { scrollUp.toggle('.jwpnavbar--scrolled') } } }); See the Pen BazvJwZ by weddje (@weddje) on CodePen Link to comment Share on other sites More sharing options...
ZachSaucier Posted November 17, 2020 Share Posted November 17, 2020 Hey weddje. I'm not quite sure I'm understanding what you're asking for. Do you want something like this? See the Pen KKMYaBK?editors=0010 by GreenSock (@GreenSock) on CodePen Link to comment Share on other sites More sharing options...
Solution weddje Posted November 17, 2020 Author Solution Share Posted November 17, 2020 hi Zach, thank you for the suggestion. I've made it work now! It works like I intended. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now