使用Fullpage.js,在scrollOverflow滚动期间是否可以报告部分内部的y位置? (使用iscroll-probe)

问题描述 投票:0回答:2

我正在使用最新版本的fullpage.js,并将scrollOverflow选项设置为true。像这个例子... http://alvarotrigo.com/fullPage/examples/scrolling.html

Fullpage.js使用iscroll.js作为此选项,我已经包含了iscroll的“探测”版本。像这个例子... http://lab.cubiq.org/iscroll5/demos/probe/

iscroll-probe报告当前正在滚动的整个“部分”的y位置?

javascript jquery fullpage.js iscroll
2个回答
4
投票

这确实是可能的。虽然iScroll库有some bugs that were solved for its use in fullpage.js和scrolloverflow.js fork。我建议你自己在iScroll Probe中进行这些更改。

关于如何获取滚动位置,只需查看您提供的源示例,以了解要使用的iscroll事件。

然后,只需获取可以使用以下内容提取的部分的iscroll实例:

$('.fp-section.active').find('.fp-scrollable').data('iscrollInstance');

或者从活动幻灯片:

$('.fp-section.active').find('.fp-slide.active').find('.fp-scrollable').data('iscrollInstance');

并使用iScroll选项probeType:3,详见其文档。为此,使用scrollOverflowOptions参数扩展默认的scrolloverflow选项。

混合在一起......

Reproduction online

$('#fullpage').fullpage({
    sectionsColor: ['yellow', 'orange', '#C0C0C0', '#ADD8E6'],
    scrollOverflow:true,
    scrollOverflowOptions: {
        probeType: 3
    },
    afterLoad: function(anchorLink, index){
       var iscroll = $('.fp-section.active').find('.fp-scrollable').data('iscrollInstance');

       if(iscroll && typeof iscroll !== undefined){
            iscroll.on('scroll', getScroll);
       }
    }
});

function getScroll(){
   console.log(this.y);
   $('#position').text(this.y);
}

-1
投票

我认为这是不可能的,因为两个插件都会尝试使用相同的“元素”,同时和不同的方式。所以,当然,它会互相冲突。对不起,请尝试另一种方式。 :/

© www.soinside.com 2019 - 2024. All rights reserved.