Jump to content

Recommended Posts

Posted

Olá

Preciso de criar um sistema que primeiramente meta o scroll à altura do ecrã (mais ou menos) e que depois à medida que se vai andando para baixo vai aumentando o scroll.

Isto para prevenir que o utilizador abra a página e veja um scroll enorme..

Alguém sabe fazer isto?

Posted (edited)

Uma solução que fiz á pata...

<div id="items_list">
<!-- bla bla bla -->

<div data-url="http://dominio.com/catalogo/pagina/2" class="load-more span10 clearfix">
	<p>Load more...</p>
</div>
</div>

<!-- infinite scroll -->
<script src="https://raw.github.com/teamdf/jquery-visible/master/jquery.visible.min.js" type="text/javascript"></script>
<script type=text/javascript>
var loading = false;

jQuery(function($) {
	$(window).scroll(function() {
		if ($('#items_list .load-more').length == 0) return;
		if (loading) return;

		var loader_visible = $('#items_list .load-more').visible();
		if (loader_visible) {
			loading = true;
			var elem = $('#items_list .load-more')[0];
			var url = $(elem).attr('data-url');
			$.get(url, function(response) {
				$(elem).remove();
				$('#items_list').append(response);
				loading = false;
			});
		}
	});
});
</script>
Edited by taviroquai

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.