Bueno os explico un poco lo que me pasa.
tengo un theme wordpress que le he añadido un scroll para pasar de post a post mediante unas imagenes.
Por defecto tengo definido dos datos para poder hacer el scroll el currentpost y el maxpost.
Código Java :
jQuery.noConflict();
jQuery(document).ready(function() {
jQuery('#navigationPost').css('display','block');
//oculto el div previous desde el principio
jQuery('#previous-post-scroll').hide();
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());
}
// activo u oculto el div previous en el primer post
var finalpost = maxposts;
var toppost = intcurrentpost;
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 quiero ocultar el div previous cuando llego al primer post usando el #previous-post-scroll
pero no consigo hacerlo, se les ocurre como hacerlo?
Gracias
