Javascript 当浏览器窗口从手机调整到平板电脑或更大时,如何启动plugin FullPage.js?
使用fullPage.js,当窗口大小低于767px时,我禁用了插件,代码如下。它可以工作,但是当我把它从767px调整到960px时,插件就不能工作了。调整大小后,有人可以帮助重新启动插件吗 JS: 函数fullPageScroll(){ $('#main')。整页({ 导航:正确 }); }Javascript 当浏览器窗口从手机调整到平板电脑或更大时,如何启动plugin FullPage.js?,javascript,jquery,fullpage.js,Javascript,Jquery,Fullpage.js,使用fullPage.js,当窗口大小低于767px时,我禁用了插件,代码如下。它可以工作,但是当我把它从767px调整到960px时,插件就不能工作了。调整大小后,有人可以帮助重新启动插件吗 JS: 函数fullPageScroll(){ $('#main')。整页({ 导航:正确 }); } 因为您还需要在调整大小事件上应用该选项: //first call when loading the site doneResizing() var resizeId; //calling the f
因为您还需要在调整大小事件上应用该选项:
//first call when loading the site
doneResizing()
var resizeId;
//calling the function again on resize so we can get the new width
$(window).resize(function () {
//in order to call the functions only when the resize is finished
clearTimeout(resizeId);
resizeId = setTimeout(doneResizing, 500);
});
//your original code
function doneResizing() {
var $win = $(window).width();
if ($win > 767) {
fullPageScroll();
} else {
fullPageScroll();
$.fn.fullpage.destroy('all');
}
}
就用这个
@media (max-width:767px){
#scroll-section{
transform: translate3d(0px, 0px, 0px) !important;
}
body {
overflow: auto !important;
}
}
如果
css3:true
,则只会打开autoScroll:true
。它不会破坏fullpage.js在网站上的效果,也不会在所有情况下都起作用。尽可能使用库函数。
@media (max-width:767px){
#scroll-section{
transform: translate3d(0px, 0px, 0px) !important;
}
body {
overflow: auto !important;
}
}