【发布时间】:2017-05-05 05:45:11
【问题描述】:
在滚动英雄后尝试启动 FullPage.JS。现在,如果您滚动过英雄 - FullPage 会被初始化并继续以初始滚动的势头滚动幻灯片。我为我的 init 准备了这个函数。
function initFullPage(){
$(".view-case-study").addClass("projects-load");
$(".pagination").addClass("visible");
$(".logo-menu svg").toggleClass("hovered");
$('#fullpage').fullpage({
lazyLoading:false,
navigation: true,
navigationPosition: 'right',
css3:true,
normalScrollElementTouchThreshold: 5,
touchSensitivity: 10,
anchors: a_anchors,
menu: '#myMenu',
normalScrollElements: '.nav, .open-nav, .project-inner, .work-mode, .menu-shelf, .tab, .view-case-study, #hero, .hero-center-container',
afterLoad: function(anchorLink, index){
var loadedSection = $(this);
projectUrl = loadedSection.data('url');
project_title = loadedSection.data('title');
loadedSection.addClass('projects-load');
loadedSection.find(".full-line").animate({'width':'100%'},500);
loadedSection.animate({'background-position-y':'-20px','background-size':'120%'},1000);
$('#hero').animate({'opacity':'0'},1000);
$('#hero').addClass('destroy');
$('.ui-info').animate({'opacity':'1'},350);
},
onLeave: function(index, nextIndex, direction){
var leavingSection = $(this);
leavingSection.removeClass('projects-load');
leavingSection.find(".full-line").animate({'width':'0%'},250);
leavingSection.animate({'background-position-y':'0px','background-size':'110%'},100);
$('#project-inner-container').animate({scrollTop:0},0);
$('.ui-info').animate({'opacity':'0'},0);
}
});
fullPageInit = true;
}
下面是我的英雄卷轴脚本。我试图初始化脚本并静默移动到第一部分,但它不想听。
var winHeight = $(window).height();
$(window).scroll(function () {
var scrTop = $(document).scrollTop() / winHeight,
scrTopFixed = scrTop.toFixed(2),
scrTransform = scrTopFixed * 80,
bgPos = scrTransform / 10 + 95,
heroOpacity = 1 - scrTransform / 100;
if ((scrTransform >= 80) && (fullPageInit == false)) {
initFullPage();
$.fn.fullpage.silentMoveTo('#sidepocket');
}
$('svg.scroll-end').css({
'clip': "rect(0px," + scrTransform + "px,200px,0px)",
});
}); // Close
【问题讨论】:
-
为什么不为英雄创建一个部分?
-
在您的示例alvarotrigo.com/fullPage/examples/scrolling.html 中,滚动势头仍然延续到下一部分。如果您快速滚动,它将继续滚动到当前幻灯片之外。我还希望滚动 svg 在删除/销毁自身并引入 section-01 之前填充
-
你的英雄使用滚动条吗?
-
@Alvaro 滚动条是隐藏的,但它使用默认的网页滚动功能来填充英雄的 svg 居中底部。
-
@Alvaro 我终于明白了!
标签: javascript jquery scroll fullpage.js