Solved

jQuery Waypoints

Posted on 2014-09-13
4
282 Views
Last Modified: 2014-09-15
Hello Experts,

I am trying to do, for the first time, something very simple using the jQuery Waypoints plugin.
I am changing the "header" classes depending on the window scroll offset.
Here is an online example: http://codepen.io/ilan-lavi/pen/scwHb

What happens is when you resize the screen (viewport) the style is gone. I was trying to fix this using the "refresh" method as in the Waypoints documentation but no luck. Please see that page link above and re-size the window.

Any help would be appreciated!
0
Comment
Question by:Refael
  • 2
  • 2
4 Comments
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
ID: 40322390
I believe you've got the waypoint on the wrong element.  Given it's the section that's scrolling, not the header, it should be initialised on that:

http://jsbin.com/sebufu/1/
0
 

Author Comment

by:Refael
ID: 40322620
Hi Rob Jurd, Thank you.

Shouldn't you apply the Waypoints on the element it self? What you are doing here is applying it to an element after the one you want to animate. What if i need to apply the same on the footer, should i then apply it to an element before it?
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
ID: 40322624
Yes that's exactly what you'd do because it's the element before it that you would be scrolling.
A little bit counter intuitive isn't it
0
 

Author Closing Comment

by:Refael
ID: 40322634
Rob Jurd Thank you!

The idea of applying the waypoints to an element before/after the element you trigger is indeed working yet in all the examples / tutorials i saw they always applying it directly on the element it self. Anyway if it works then it works :-)
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now