【发布时间】:2023-02-24 19:31:33
【问题描述】:
我正在使用 https://alvarotrigo.com/fullPage/docs/ 插件(jQuery 版本)
我有四个垂直部分并在 html 中一一显示,但在第三部分中有冗长的内容,我必须调整滚动(窗口.scrollTo()) 基于列表项的 offseTop 点击
Window.scrollTo() is not working so Im trying to do with this solution but I am not getting the accurate calculation , it seems its not a right solution**
let elem = document.querySelector(".active");
$('.active-section .fp-scroller').css({'transform': `translate(0, -${elem.offsetTop}px)`});
$('.active-section .iScrollIndicator').css({'transform': `translate(0, ${ $('.active-section').height() - elem.offsetTop }px)`});
==========================================
<div class="wrapper">
<section class="section one"> One </section>
<section class="section two"> two </section>
<section class="section three"> three - (here there is listing <li> </li>... )</section>
<section class="section four"> four </section>
</div>
$('li').click( function(){
let ind = $('.animate-section.active').index();
$.fn.fullpage.reBuild();
$.fn.fullpage.silentMoveTo(ind + 1);
$('li').removeClass('active');
$(this).addClass('active');
let elem = document.querySelector(".active");
$('.active-section .fp-scroller').css({'transform': `translate(0, -${elem.offsetTop}px)`});
$('.active-section .iScrollIndicator').css({'transform': `translate(0, ${ $('.active-section').height() - elem.offsetTop }px)`});
});
$('.wrapper').fullpage({
sectionSelector: '.section',
navigation: false,
normalScrollElements:,
scrollOverflow: true,
onLeave: function (origin, destination, direction, trigger) {
},
afterLoad: function (origin, destination, direction, trigger) {
},
});
【问题讨论】:
标签: javascript jquery fullpage.js