Solved

jQuery Waypoints

Posted on 2014-09-13
4
294 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 43

Accepted Solution

by:
Rob 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 43

Expert Comment

by:Rob
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article you'll learn how to use Ajax calls within your CodeIgniter application. To explain this, I'll illustrate how to implement a simple contact form to allow visitors to send you an email through your web site.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

820 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