jquery.fullPage.js全屏滚动插件的使用方法

来源:互联网 发布:淘宝透明下拉栏 编辑:程序博客网 时间:2024/05/17 22:21

兼容性:

  1. 支持 IE8+ 及其他现代浏览器。

主要功能:

1.支持鼠标滚动;

2.支持前进后退键盘控制;

3.多个回调函数;

4.支持手机.移动设备;

5.支持窗口缩放自动调整;

6.可设置滚动宽度、背景颜色、滚动速度、循环选项、回调、文本对齐方式等等;

7.支持CSS3动画;

github下载地址:https://github.com/alvarotrigo/fullPage.js

滚屏里面的效果,都是写在回调函数中的;

配置表:

1.选项

选项类型默认值说明verticalCentered字符串true内容是否垂直居中resize布尔值false字体是否随着窗口缩放而缩放slidesColor函数设置背景颜色anchors数组定义锚链接scrollingSpeed整数700滚动速度,单位为毫秒easing字符串easeInQuart滚动动画方式menu布尔值false绑定菜单,设定的相关属性与 anchors 的值对应后,菜单可以控制滚动navigation布尔值false是否显示项目导航navigationPosition字符串right项目导航的位置,可选 left 或 rightnavigationColor字符串#000项目导航的颜色navigationTooltips数组项目导航的 tipslidesNavigation布尔值false是否显示左右滑块的项目导航slidesNavPosition字符串bottom左右滑块的项目导航的位置,可选 top 或 bottomcontrolArrowColor字符串#fff左右滑块的箭头的背景颜色loopBottom布尔值false滚动到最底部后是否滚回顶部loopTop布尔值false滚动到最顶部后是否滚底部loopHorizontal布尔值true左右滑块是否循环滑动autoScrolling布尔值true是否使用插件的滚动方式,如果选择 false,则会出现浏览器自带的滚动条scrollOverflow布尔值false内容超过满屏后是否显示滚动条css3布尔值false是否使用 CSS3 transforms 滚动paddingTop字符串0与顶部的距离paddingBottom字符串0与底部距离fixedElements字符串 normalScrollElements  keyboardScrolling布尔值true是否使用键盘方向键导航touchSensitivity整数5 continuousVertical布尔值false是否循环滚动,与 loopTop 及 loopBottom 不兼容animateAnchor布尔值true normalScrollElementTouchThreshold整数5

 

2.方法:

  • moveSectionUp() 向上滚动
  • moveSectionDown() 向下滚动
  • moveTo(section, slide) 滚动到
  • moveSlideRight() slide 向右滚动
  • moveSlideLeft() slide 向左滚动
  • setAutoScrolling() 设置页面滚动方式,设置为 true 时自动滚动
  • setAllowScrolling() 添加或删除鼠标滚轮/触控板控制
  • setKeyboardScrolling()添加或删除键盘方向键控制
  • setScrollingSpeed() 定义以毫秒为单位的滚动速度

 

3、回调函数

 

名称说明afterLoad滚动到某一屏后的回调函数,接收 anchorLink 和 index 两个参数,anchorLink 是锚链接的名称,index 是序号,从1开始计算onLeave滚动前的回调函数,接收 index、nextIndex 和 direction 3个参数:index 是离开的“页面”的序号,从1开始计算;

 

nextIndex 是滚动到的“页面”的序号,从1开始计算;

direction 判断往上滚动还是往下滚动,值是 up 或 down。

afterRender页面结构生成后的回调函数,或者说页面初始化完成后的回调函数afterSlideLoad滚动到某一水平滑块后的回调函数,与 afterLoad 类似,接收 anchorLink、index、slideIndex、direction 4个参数onSlideLeave某一水平滑块滚动前的回调函数,与 onLeave 类似,接收 anchorLink、index、slideIndex、direction 4个参数
个别代码示例:
$(function(){    //fullpage.js全屏滚动插件效果;    $('#dowebok').fullpage({        sectionsColor: ['#1bbc9b', '#4BBFC3', '#7BAABE', '#f90'],        //滚动到某一屏后调用js代码        afterLoad: function(anchorLink, index){            if(index == 2){                //进入第二个页面左边的div出现的效果;                $('.animation_effect .left').delay(500).animate({                    width: '60%'                }, 1500, 'easeOutExpo');                //进入第二个页面右边三个div出现的效果;                $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').delay(500).animate({                    width:'40%'                },1500,'easeOutExpo');                //鼠标进入左边的div,左边的div和右边三个div宽度发生变化;                $('.animation_effect .left').mouseover(function(){                    $(this).stop().animate({                        width:'69%'                    },1500, 'easeOutExpo');                    $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').stop().animate({                        width:'31%'                    },1500,'easeOutExpo')                });                //鼠标离开左边的div,左边div和右边div宽度发生变化;                $('.animation_effect .left').mouseout(function(){                    $(this).stop().animate({                        width:'60%'                    },1500, 'easeOutExpo');                    $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').stop().animate({                        width:'40%'                    },1500,'easeOutExpo')                });                //鼠标在左边的left的div中指定的坐标内移动的时候;                $('.left').mousemove(function(e){                    //console.log(e.offsetX +":" + e.offsetY)                    if(e.offsetX>460){                        //$('.animation_effect .left').stop().animate({                        //    width:'69-460'+e.offsetX+'%'                        //},1500, 'easeOutExpo');                        console.log("dasfaf")                    }                })                //鼠标进入右边的三个div,四个div出现的效果                $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').mouseover(function(){                    $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').stop().animate({                        width:'49%'                    },1500,'easeOutExpo');                    $('.animation_effect .left').stop().animate({                        width:'51%'                    },1500, 'easeOutExpo');                })                //鼠标离开右边的三个div,四个div出现的效果;                $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').mouseout(function(){                    $('.animation_effect .top,.animation_effect .center,.animation_effect .bottom').stop().animate({                        width:'40%'                    },1500,'easeOutExpo');                    $('.animation_effect .left').stop().animate({                        width:'60%'                    },1500, 'easeOutExpo');                })            }            //当页面在首页的时候,点击视频关闭按钮,出现的效果;            if(index == 1){                        }            if(index == 4){                $('.section4').find('p').fadeIn(2000);            }        },        //滚动到某一屏前,或者这一屏幕滚动过后执行的js代码;        onLeave: function(index, direction){            if(index == '2'){                $('.left').delay(450).animate({                    width: '100%'                }, 1500, 'easeOutExpo');                $('.top,.center,.bottom').delay(450).animate({                    width:'0'                },1500,'easeOutExpo')            }            if(index == '3'){                $('.section3').find('p').delay(500).animate({                    bottom: '-120%'                }, 1500, 'easeOutExpo');            }            if(index == '4'){               $('.section4').find('p').fadeOut(2000);            }        }    });});


原创粉丝点击