Foros del Web » Programando para Internet » Javascript »

problema añadiendo .hide()

Estas en el tema de problema añadiendo .hide() en el foro de Javascript en Foros del Web. hola mirar estoy usando jquery + scrollto + un pequeño codigo para desplazarme por diferentes sitio del index con animacion, pero resulta que el codigo ...
  #1 (permalink)  
Antiguo 06/09/2010, 13:35
Avatar de 23r9i0  
Fecha de Ingreso: noviembre-2008
Ubicación: Catalonia
Mensajes: 203
Antigüedad: 15 años, 5 meses
Puntos: 33
problema añadiendo .hide()

hola mirar estoy usando jquery + scrollto + un pequeño codigo para desplazarme por diferentes sitio del index con animacion, pero resulta que el codigo original solo desplazaba pero no ocultaba la flecha que no deberia usar. No se si me he explicado.
Podeis ver un ejemplo de lo que digo en este [URL="http://www.woothemes.com/demo/?name=slanted"]sitio[/URL]. Yo me he inspirado en este sitio para hacerlo pero yo de entrada no muestro la flecha hacia arriba cuando estoy al principio y el scrollto cuando llego al final de los post lo hago hasta el final. Pero tengo un problema y es que me gustaria volver a ocultar la flecha hacia arriba cuando voy hacia atras y llego al primer post.
Código:
jQuery.noConflict();
jQuery(document).ready(function() {
// activo la seccion cuando tengo activo el javascript en el navegador
	jQuery('#navigationPost').css('display','block');
//Oculto la flecha de retroceder
	jQuery('#previous-post-scroll').hide();
//Aqui empieza el codigo original!!!
	jQuery('#next-post-scroll').click(function() {
		scrollnext();
		return false;
	});
	
	jQuery('#previous-post-scroll').click(function() {
		scrollprevious();
		return false;
	});
	
	jQuery('#post-scroll').click(function() {
		scrollprevious();
		return false;
	});
	
	jQuery('#comments-scroll').click(function() {
		scrollnext();
		return false;
	});
});

function scrollnext() {
	if (jQuery('#comments-scroll').length) {
		var windowobject = window.pageYOffset;
		var postobject = jQuery('#comments');
		var postposition = postobject.offset().top;
		var calculatedposition = windowobject + 20;
		if (calculatedposition === postposition) {
		}
		else {
			var postobject = jQuery('#comments');
			var postposition = postobject.offset().top;
			jQuery('html,body').animate({scrollTop: postposition - 20}, 800);
		}
	}
	else {
		
		var currentpost = jQuery('#currentpost').text();
		var maxposts = jQuery('#maxposts').text();
		
		var intcurrentpost = currentpost * 1;
		var intmaxposts = maxposts * 1;
			
		var incrementpost = 0;
		if (intcurrentpost == intmaxposts) {
			incrementpost = 1;
		}
		else {
			incrementpost = intcurrentpost + 1;
		}
		var postobject = jQuery('#postcount-' + incrementpost.toString());
		var postposition = postobject.offset().top;
		jQuery('html,body').animate({scrollTop: postposition - 20}, 800);

		jQuery('#currentpost').text(incrementpost.toString());	
	}
// el siguiente codigo lo añadi para hacer el scroll hasta arriba cuando llegaba al final de los post
		var finalpost = maxposts;
		var toppost = incrementpost * 2;
		var top = ('#page');
		if (toppost < finalpost) {
			jQuery('html,body').animate({scrollTop: top}, 800);
			jQuery('#previous-post-scroll').hide();
		} else {
			jQuery('#previous-post-scroll').show();
		}
}

function scrollprevious() {
	if (jQuery('#post-scroll').length) {
		var windowobject = window.pageYOffset;
		var postobject = jQuery('#main div.post');
		var postposition = postobject.offset().top;
		var calculatedposition = windowobject + 20;
		if (calculatedposition === postposition) {
		}
		else {
			var postobject = jQuery('#main div.post');
			var postposition = postobject.offset().top;
			jQuery('html,body').animate({scrollTop: postposition - 20}, 800);
		}
	}
	else {
		var currentpost = jQuery('#currentpost').text();
		var maxposts = jQuery('#maxposts').text();
		
		var intcurrentpost = currentpost * 1;
		var intmaxposts = maxposts * 1;
		
		var incrementpost = 0;
		if (intcurrentpost <= 1) {
			incrementpost = intmaxposts;
		}
		else {	
			incrementpost = intcurrentpost - 1;
		} 
		
		var postobject = jQuery('#postcount-' + incrementpost.toString());
		var postposition = postobject.offset().top;
		jQuery('html,body').animate({scrollTop: postposition - 20}, 800);

		jQuery('#currentpost').text(incrementpost.toString());
	}
}
El problema es que no consigo que al hacer click en #previous-post-scroll y llege al primero desaparezca la opcion de seguir clickando para que no vuelva al ultimo post y empieze de nuevo.
Gracias!!

Etiquetas: hide
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:16.