Skip to content
prebenh edited this page Apr 16, 2012 · 9 revisions

jQuery Scroll Up

jQuery scroll up is u plugin to load content when scrolling to the top of an element or a window.
Just like Facebook messages are loaded when you scroll up.

Wiring up the plugin to an element

$('#content').scrollUp({'contentType' : 'POST', //the type of the request
		'contentPage': '', // the page where you are searching for results
		'contentData': {}, // you can pass the children().size() to know where is the pagination
		'scrollTarget': $(window), // who gonna scroll? in this example, the full window
		'heightOffset': 100, // how many pixels before reaching begin of the page would loading start? positives numbers only please
		'beforeLoad': function(){ // before load, some function, maybe display a preloader div
			$('#loading').fadeIn();	
		},
		'afterLoad': function(elementsLoaded){ // after loading, some function to animate results and hide a preloader div
			 $('#loading').fadeOut();
			 var i = 0;
			 $(elementsLoaded).fadeInWithDelay();
			 if ($('#content').children().size() > 100){ // if more than 100 results loaded stop pagination (only for example)
			 	$('#nomoreresults').fadeIn();
				$('#content').stopScrollUp();
			 }
		});
Clone this wiki locally