Solved

jQuery Waypoints

Posted on 2014-09-13
4
300 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
This article discusses how to implement server side field validation and display customized error messages to the client.
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)

737 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