On my app i have 10 images which are all 200px x 200px, when i scroll i want to increase the top image to 400px x 400px
I have this so far to check if i am scrolling onto a div to change the size:
http://jsfiddle.net/c02m1q7w/6/
$.fn.isOnScreen = function(){
var win = $(window);
var viewport = {
top : win.scrollTop(),
left : win.scrollLeft()
};
viewport.right = viewport.left + win.width();
viewport.bottom = viewport.top + win.height();
var bounds = this.offset();
bounds.right = bounds.left + this.outerWidth();
bounds.bottom = bounds.top + this.outerHeight();
return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
};
$(window).scroll(function(){
if($('#boxorange').isOnScreen() == true){
$('#boxorange').css({"height":"400px"});
$('#boxorange').css({"width":"400px"});
} else{
$('#boxorange').css({"height":"200px"});
$('#boxorange').css({"width":"200px"}); }
});
But without creating separate if statements each time, which ever div is on top of the screen i want to increase in size but i am having no luck