This is probably a simple question but I need some help.
I have this code:
var lastitem='';
(function($) {
var allPanels = $('.accordion> dd').hide();
$('.accordion > dt > a').click(function() {
allPanels.slideUp();
if ($(this).text() != lastitem) {
$(this).parent().next().slideDown();
lastitem = $(this).text();
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start" // or "end"
});
} else {
lastitem = '';
};
return false;
});
})(jQuery);
And I have a fixed header, so when I click on the accordion it scrolls into viewport, the problem is my fixed header. I would need to scroll into viewport + 100px from top.
Something like:
$(this).get(0).scrollIntoView({
behavior: "smooth", // or "auto" or "instant"
block: "start + 100px" // or "end"
});
That's all, any suggestion? thank you!!