@kexinWeb
2017-03-04T01:37:52.000000Z
字数 5386
阅读 2309
fullpage plugin
fullPage插件是基于jquery框架开发的一个全屏滚动插件,它能够很轻松很方便地做出漂亮的全屏单页网站。
npm install fullpage.js
bower 安装
boewr install fullpage.js
官网下载安装
直接引入cdnjs站点上的文件
https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.3/jquery.fullpage.css
https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.3/jquery.fullpage.js
<link rel="stylesheet" href="css/jquery.fullPage.css"><script src="js/jquery.min.js"></script><script src="js/jquery.fullPage.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.3/jquery.fullpage.css"><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/2.9.3/jquery.fullpage.js"></script>
注意: 由于fullpage插件依赖于jquery框架,所以jquery框架要在fullpage前面引用。
<div id='fullpage'><div class="section">第一屏</div><div class="section"><div class="slide"> slide1 </div><div class="slide"> slide2 </div><div class="slide"> slide3 </div></div><div class="section">第三屏</div><div class="section">第四屏</div><div class="section">第五屏</div></div>
<script type="text/javascript">$(function() {$('#fullpage').fullpage();});</script>
//当页面加载完毕之后执行函数$(document).ready(function() {//配置fullpage$('#fullpage').fullpage({//Navigationmenu: false,//绑定菜单,设定的相关属性与 anchors 的值对应后,菜单可以控制滚动lockAnchors: false,//锁定锚链接不随页面滑动而改变anchors:['firstPage', 'secondPage'],//锚链接,数组中元素对应各个页面的锚链接navigation: false,//有无导航栏navigationPosition: 'right',//导航栏位置navigationTooltips: ['firstSlide', 'secondSlide'],//导航栏提示文字,与页面一一对应showActiveTooltip: false,//是否显示当前页面提示文字slidesNavigation: true,//有无幻灯片(横向)导航栏slidesNavPosition: 'bottom',//幻灯片(横向)导航栏位置//Scrollingcss3: true,//是否支持css3动画scrollingSpeed: 700,//滚动速度,以毫秒为单位autoScrolling: true,//是否自动滑动fitToSection: true,//每一屏是否自动适应视窗(viewport)大小scrollBar: false,//是否有滚动条easing: 'easeInOutCubic',//全屏滚动效果,需要jquery.easing.js或者jqueryUI的支持easingcss3: 'ease',//css3动画过度效果loopBottom: false,loopTop: false,loopHorizontal: true,continuousVertical: false,normalScrollElements: '#element1, .element2',//设置不受默认滚动行为限制的正常滚动的元素scrollOverflow: false,//页面内容溢出后是否隐藏touchSensitivity: 15,//触摸敏感度normalScrollElementTouchThreshold: 5,//AccessibilitykeyboardScrolling: true,animateAnchor: true,recordHistory: true,//是否把滚动状态记入浏览器的历史记录里//DesigncontrolArrows: true,//幻灯片滚动控制箭头verticalCentered: true,//section内容是否垂直居中resize : false,//字体大小是否根据窗口大小sectionsColor : ['#ccc', '#fff'],//每一页的背景颜色paddingTop: '3em',//section内上边距paddingBottom: '10px',//section内下边距fixedElements: '#header, .footer',//固定的元素,如主导航栏responsiveWidth: 0,responsiveHeight: 0,//官方文档:A normal scroll (autoScrolling:false) will be used under the defined height in pixels. A class fp-responsive is added to the body tag in case the user wants to use it for his own responsive CSS. For example, if set to 900, whenever the browser's height is less than 900 the plugin will scroll like a normal site.//Custom selectorssectionSelector: '.section',//当页面重新加载的时候直接定位到指定的sectionslideSelector: '.slide',//当页面重新加载的时候直接定位到指定的slide//callbackonLeave: function(index, nextIndex, direction){},//离开sectionafterLoad: function(anchorLink, index){},//加载完sectionafterRender: function(){},//渲染整个页面后afterResize: function(){},//重新resize之后afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex){},//加载完某一个slide后 slideIndex)onSlideLeave: function(anchorLink, index, slideIndex, direction, nextSlideIndex){}//离开某一个slide后});});
$.fn.fullpage.moveSectionUp();
$.fn.fullpage.moveSectionDown();
$.fn.fullpage.moveTo('firstSlide', 2);
$.fn.fullpage.moveTo(3, 0);
$.fn.fullpage.silentMoveTo('firstSlide', 2);
$.fn.fullpage.moveSlideLeft();
moveSlideRight()也是如此
$.fn.fullpage.moveSlideRight();
$.fn.fullpage.setAutoScrolling(false);
$.fn.fullpage.setFitToSection(false);
$.fn.fullpage.setLockAnchors(false);
disabling scrolling
$.fn.fullpage.setAllowScrolling(false);
disabling scrolling down
$.fn.fullpage.setAllowScrolling(false, 'down');
disabling scrolling down and right
$.fn.fullpage.setAllowScrolling(false, 'down, right');
disabling all keyboard scrolling
$.fn.fullpage.setKeyboardScrolling(false);
disabling keyboard scrolling down
$.fn.fullpage.setKeyboardScrolling(false, 'down');
disabling keyboard scrolling down and right
$.fn.fullpage.setKeyboardScrolling(false, 'down, right');
$.fn.fullpage.setRecordHistory(false);
$.fn.fullpage.setScrollingSpeed(700);
$.fn.fullpage.destroy();
destroying all Javascript events and any modification done by fullPage.js over your original HTML markup.
$.fn.fullpage.destroy('all');
$.fn.fullpage.reBuild();
<ul id="myMenu"><li data-menuanchor="firstPage" class="active"><a href="#firstPage">First section</a></li><li data-menuanchor="secondPage"><a href="#secondPage">Second section</a></li><li data-menuanchor="thirdPage"><a href="#thirdPage">Third section</a></li><li data-menuanchor="fourthPage"><a href="#fourthPage">Fourth section</a></li></ul>
$('#fullpage').fullpage({anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],menu: '#myMenu'});
只需要给Section添加.fp-auto-height类就可以实现自定义高度。
https://github.com/alvarotrigo/fullPage.js#options
https://www.uedsc.com/fullpage.html
http://www.uedsc.com/fullpage-introduction.html