I have got a fixed div and when starting to scroll I need the div to add a class.
I have this below but it doesn't work.
http://fiddle.jshell.net/fourroses666/ztysfz9u/
Anyone an idea how to fix?
Evolution user, I like the back-end speed and simplicity

Something like?
http://fiddle.jshell.net/ztysfz9u/3/
var currentScrollPos = 0;
$(window).scroll(function () {
var topScrollPos = $(this).scrollTop();
if (currentScrollPos > topScrollPos) {
//Scrolling Down
$(".top").addClass("smaller");
} else {
//Scrolling Up
$(".top").removeClass("smaller");
}
currentScrollPos = topScrollPos;
});
TinymceWrapper: Complete back/frontend content solution.
Harden your MODX site by
passwording your three main folders:
core, manager, connectors and renaming your
assets (thank me later!)
5 ways to sniff / hack your own sites; even with renamed/hidden folders, burst them all up, to see how secure you are not.
Hey thanks, but I need to add the class when reaching position 1px from the top.
So when scrolling it adds the class. when scrolling up it keeps the class till we reach 0 px from the top.
Evolution user, I like the back-end speed and simplicity

I found something
http://jsfiddle.net/sinky/S8Fnq/
$(window).on("scroll touchmove", function () {
$('.top').toggleClass('smaller', $(document).scrollTop() > 0);
});
Evolution user, I like the back-end speed and simplicity
