Difference between revisions of "Template:UNITN-Trento/JSnotebookFunctions"
m |
m (added function scrollAndHighlight -K) |
||
Line 35: | Line 35: | ||
$('.button.active').removeClass('active'); | $('.button.active').removeClass('active'); | ||
$('#'+ida+'_btn').addClass('active'); | $('#'+ida+'_btn').addClass('active'); | ||
+ | } | ||
+ | |||
+ | function scrollAndHighlight(ida) | ||
+ | { | ||
+ | if ($('#'+ida).length) { | ||
+ | $('body').scrollTo('#'+ida,{axis: 'y',duration: 350,margin:true}); | ||
+ | $('.highlighted').removeClass('highlighted'); | ||
+ | $('#'+ida).next().addClass('highlighted'); | ||
+ | return false; //scroll and don't change | ||
+ | } | ||
} | } | ||
Latest revision as of 12:12, 12 September 2015
function showBlocks(blocks, offset) { blocks.each(function(){ ( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.cd-timeline-img').hasClass('is-hidden') ) && $(this).find('.cd-timeline-img, .cd-timeline-content').removeClass('is-hidden').addClass('bounce-in'); }); }
function scrollandfade(ida) { var LCLtimelineBlocks = $('#'+ida+' .cd-timeline-block');
$('.button.active').removeClass('active'); $('#'+ida+'_btn').addClass('active');
$('#'+ida).siblings().css('display','none'); $('.cd-timeline-img, .cd-timeline-content').removeClass('bounce-in').addClass('is-hidden');
$(window).on('scroll', function(){
(!window.requestAnimationFrame) ? setTimeout(function(){ showBlocks(LCLtimelineBlocks, 0.8); }, 100) : window.requestAnimationFrame(function(){ showBlocks(LCLtimelineBlocks, 0.8); }); });
$('#'+ida).fadeIn(100,function(){
$('body').scrollTo('#main',{axis: 'y',duration: 350,margin:true,offset: -80});
});
return false;
}
function scrollToID(ida){ $('body').scrollTo('#'+ida,{axis: 'y',duration: 350,margin:true}); $('.button.active').removeClass('active'); $('#'+ida+'_btn').addClass('active'); }
function scrollAndHighlight(ida) { if ($('#'+ida).length) { $('body').scrollTo('#'+ida,{axis: 'y',duration: 350,margin:true}); $('.highlighted').removeClass('highlighted'); $('#'+ida).next().addClass('highlighted'); return false; //scroll and don't change } }
function checkAndScrollTo(ida){ if ($('#'+ida).length) { $('body').scrollTo('#'+ida,{axis: 'y',duration: 350,margin:true}); return false; //scroll and don't change } else return true; //go on and change page
}
function showAftPar(ob) { if(jQuery(ob).parent().next().css('display') == 'none') { jQuery(ob).find('.fa').addClass('spinnable'); jQuery(ob).parent().next().fadeIn(200);
}else { jQuery(ob).parent().next().fadeOut(200,function(){jQuery(ob).find('.fa').removeClass('spinnable'); });
} }