Is it possible to dynamically add a class to a div element based on the user's scrolling behavior? For example, I would like to add a class when the user scrolls 200px down the page, and then remove it when they scroll 300px down. Similarly, I want to add the class again when the user scrolls back up to 300px from the top, and remove it at 200px.
Despite trying multiple variations, I seem to be struggling with the approach. You can view my current progress on JSFiddle here: http://jsfiddle.net/v8my3sr1/
$(window).on('scroll',function() {
var scroll = $(window).scrollTop();
if (scroll >= 200) {
$(".trigger").addClass("wow");
} else {
$(".trigger").removeClass("wow");
}
});