MKSabzi
MKSabzi

Reputation: 69

how can i resize image(logo) when scroll down the web page

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

http://jsfiddle.net/TwLuE/

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

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

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

Related Questions