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:
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.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());
}
}
Gracias!!


