Reputation: 69
how could the reverse this function, i want to image(site logo) element resize(smaller) when scroll down the web page and back when scroll to top of page
I tried this:
$(window).on("scroll", function() {
var s = Math.min(400, $(document).scrollTop()) + 100;
$("img").width(s).height(s);
});
but it works vice versa. apologize me for weak writing question in english.
Upvotes: 1
Views: 7212
Reputation: 167172
Add a prefix size in front:
$(window).on("scroll", function() {
var s = 400 - Math.min(400, $(document).scrollTop());
$("img").width(s).height(s);
});
Tweak that 400
to your needs. :)
Fiddle: http://jsfiddle.net/pur9ruut/
Upvotes: 1