Solved

jQuery Waypoints

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Uncaught Type error cannot assign to read only property 6 27
javascript: add id amounts 5 47
Simple Total function not working 8 31
JS does not refresh 6 20
What is a Lightbox? A Lightbox is the effect you see when you click, for example, an image and the screen fades out and up pops the same image but in its full size dimensions. There are lots of Lightbox effects for jQuery. Problem is they are a…
PROBLEM: The other day I was working on adding an ajax request to a webpage that already had a dialog box on the page.  The dialog box was using relative positioning to be positioned next to a form field I had on the page.  Everything was working…
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)

777 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