iis服务器助手广告广告
返回顶部
首页 > 资讯 > 前端开发 > JavaScript >fullpage.js全屏滚动的具体使用方法
  • 204
分享到

fullpage.js全屏滚动的具体使用方法

2024-04-02 19:04:59 204人浏览 安东尼
摘要

1.fullpage.js  下载地址 https://GitHub.com/alvarotriGo/fullPage.js  2.fullPage.js 是一个

1.fullpage.js  下载地址

https://GitHub.com/alvarotriGo/fullPage.js

 2.fullPage.js 是一个基于 Jquery插件,它能够很方便、很轻松的制作出全屏网站,主要功能有:

  • 支持鼠标滚动
  • 支持前进后退和键盘控制
  • 多个回调函数
  • 支持手机、平板触摸事件
  • 支持 css3 动画
  • 支持窗口缩放
  • 窗口缩放时自动调整
  • 可设置滚动宽度、背景颜色、滚动速度、循环选项、回调、文本对齐方式等等

3.在相应的html页面中引入一下文件


<link rel="stylesheet" href="CSS/jquery.fullPage.css" rel="external nofollow" >

<script src="js/jquery.min.js"></script>
 
<!-- jquery.easings.min.js 是必须的,用于 easing 参数,也可以使用完整的 jQuery UI 代替 -->
<script src="js/jquery.easings.min.js"></script>
 
<!-- 如果 scrollOverflow 设置为 true,则需要引入 jquery.slimscroll.min.js,一般情况下不需要 -->
<script src="js/jquery.slimscroll.min.js"></script>
 
<script src="js/jquery.fullPage.js"></script>

4.<body>部分



<ul id="menu">
    <li data-menuanchor="page1" class="active">
        <a href="#page1" rel="external nofollow" >第一屏</a>
    </li>
    <li data-menuanchor="page2">
        <a href="#page2" rel="external nofollow" >第二屏</a>
    </li>
    <li data-menuanchor="page3">
        <a href="#page3" rel="external nofollow" >第三屏</a>
    </li>
    <li data-menuanchor="page4">
        <a href="#page4" rel="external nofollow" >第四屏</a>
    </li>
</ul>

$.fn.fullpage.moveTo('firstSlide', 2);
//Scrolling to the 3rd section in the site
$.fn.fullpage.moveTo(3, 0);

//Which is the same as
$.fn.fullpage.moveTo(3);
silentMoveTo(section, slide)
Demo Exactly the same as moveTo but in this case it perfORMs the scroll without animation. A direct jump to the destination.


$.fn.fullpage.silentMoveTo('firstSlide', 2);
moveSlideRight()
Demo Scrolls the horizontal slider of the current section to the next slide:

$.fn.fullpage.moveSlideRight();
moveSlideLeft()
Demo Scrolls the horizontal slider of the current section to the previous slide:

$.fn.fullpage.moveSlideLeft();
setAutoScrolling(boolean)
Demo Sets the scrolling configuration in real time. Defines the way the page scrolling behaves. If it is set to true, it will use the "automatic" scrolling, otherwise, it will use the "manual" or "normal" scrolling of the site.

$.fn.fullpage.setAutoScrolling(false);
setFitToSection(boolean)
Demo Sets the value for the option fitToSection determining whether to fit the section in the screen or not.

$.fn.fullpage.setFitToSection(false);
fitToSection()
Demo Scrolls to the nearest active section fitting it in the viewport.

$.fn.fullpage.fitToSection();
setLockAnchors(boolean)
Demo Sets the value for the option lockAnchors determining whether anchors will have any effect in the URL or not.

$.fn.fullpage.setLockAnchors(false);
setAllowScrolling(boolean, [directions])
Demo Adds or remove the possibility of scrolling through sections/slides by using the mouse wheel/trackpad or touch gestures (which is active by default). Note this won't disable the keyboard scrolling. You would need to use seTKEyboardScrolling for it.

directions: (optional parameter) Admitted values: all, up, down, left, right or a combination of them separated by commas like down, right. It defines the direction for which the scrolling will be enabled or disabled.
//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');
setKeyboardScrolling(boolean, [directions])
Demo Adds or remove the possibility of scrolling through sections by using the keyboard (which is active by default).

directions: (optional parameter) Admitted values: all, up, down, left, right or a combination of them separated by commas like down, right. It defines the direction for which the scrolling will be enabled or disabled.
//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');
setRecordHistory(boolean)
Demo Defines whether to record the history for each hash change in the URL.

$.fn.fullpage.setRecordHistory(false);
setScrollingSpeed(milliseconds)
Demo Defines the scrolling speed in milliseconds.

$.fn.fullpage.setScrollingSpeed(700);
destroy(type)
Demo Destroys the plugin events and optionally its HTML markup and styles. ideal to use when using ajax to load content.

type: (optional parameter) can be empty or all. If all is passed, the HTML markup and styles used by fullpage.js will be removed. This way the original HTML markup, the one used before any plugin modification is made, will be maintained.
//destroying all javascript events created by fullPage.js (scrolls, hashchange in the URL...)
$.fn.fullpage.destroy();

//destroying all Javascript events and any modification done by fullPage.js over your original HTML markup.
$.fn.fullpage.destroy('all');
reBuild()
Updates the DOM structure to fit the new window size or its contents. Ideal to use in combination with AJAX calls or external changes in the DOM structure of the site, specially when using scrollOverflow:true.

$.fn.fullpage.reBuild();
setResponsive(boolean)
Demo Sets the responsive mode of the page. When set to true the autoScrolling will be turned off and the result will be exactly the same one as when the responsiveWidth or responsiveHeight options get fired.

$.fn.fullpage.setResponsive(true);
responsiveSlides.toSections()
Extension of fullpage.js. Requires fullpage.js >= 2.8.5. Turns horizontal slides into vertical sections.

$.fn.fullpage.responsiveSlides.toSections();
responsiveSlides.toSlides()
Extension of fullpage.js. Requires fullpage.js >= 2.8.5. Turns back the original slides (now converted into vertical sections) into horizontal slides again.

$.fn.fullpage.responsiveSlides.toSlides();
Callbacks
Demo You can see them in action here.

afterLoad (anchorLink, index)
Callback fired once the sections have been loaded, after the scrolling has ended. Parameters:

anchorLink: anchorLink corresponding to the section.
index: index of the section. Starting from 1.
In case of not having anchorLinks defined in the plugin the index parameter would be the only one to use.

Example:

$('#fullpage').fullpage({
    anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],

    afterLoad: function(anchorLink, index){
        var loadedSection = $(this);

        //using index
        if(index == 3){
            alert("Section 3 ended loading");
        }

        //using anchorLink
        if(anchorLink == 'secondSlide'){
            alert("Section 2 ended loading");
        }
    }
});
onLeave (index, nextIndex, direction)
This callback is fired once the user leaves a section, in the transition to the new section. Returning false will cancel the move before it takes place.

Parameters:

index: index of the leaving section. Starting from 1.
nextIndex: index of the destination section. Starting from 1.
direction: it will take the values up or down depending on the scrolling direction.
Example:

$('#fullpage').fullpage({
    onLeave: function(index, nextIndex, direction){
        var leavingSection = $(this);

        //after leaving section 2
        if(index == 2 && direction =='down'){
            alert("Going to section 3!");
        }

        else if(index == 2 && direction == 'up'){
            alert("Going to section 1!");
        }
    }
});
Cancelling the scroll before it takes place
You can cancel the scroll by returning false on the onLeave callback:

$('#fullpage').fullpage({
    onLeave: function(index, nextIndex, direction){
        //it won't scroll if the destination is the 3rd section
        if(nextIndex == 3){
            return false;
        }
    }
});
afterRender()
This callback is fired just after the structure of the page is generated. This is the callback you want to use to initialize other plugins or fire any code which requires the document to be ready (as this plugin modifies the DOM to create the resulting structure). See FAQs for more info.

Example:

$('#fullpage').fullpage({
    afterRender: function(){
        var pluginContainer = $(this);
        alert("The resulting DOM structure is ready");
    }
});
afterResize()
This callback is fired after resizing the browser's window. Just after the sections are resized.

Example:

$('#fullpage').fullpage({
    afterResize: function(){
        var pluginContainer = $(this);
        alert("The sections have finished resizing");
    }
});
afterResponsive(isResponsive)
This callback is fired after fullpage.js changes from normal to responsive mode or from responsive mode to normal mode.

Parameters:

isResponsive: boolean that determines if it enters into responsive mode (true) or goes back to normal mode (false).
Example:

$('#fullpage').fullpage({
    afterResponsive: function(isResponsive){
        alert("Is responsive: " + isResponsive);
    }
});
afterSlideLoad (anchorLink, index, slideAnchor, slideIndex)
Callback fired once the slide of a section have been loaded, after the scrolling has ended. Parameters:

anchorLink: anchorLink corresponding to the section.
index: index of the section. Starting from 1.
slideAnchor: anchor corresponding to the slide (in case there is)
slideIndex: index of the slide. Starting from 1. (the default slide doesn't count as slide, but as a section)
In case of not having anchorLinks defined for the slide or slides the slideIndex parameter would be the only one to use. Example:

$('#fullpage').fullpage({
    anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'],

    afterSlideLoad: function( anchorLink, index, slideAnchor, slideIndex){
        var loadedSlide = $(this);

        //first slide of the second section
        if(anchorLink == 'secondPage' && slideIndex == 1){
            alert("First slide loaded");
        }

        //second slide of the second section (supposing #secondSlide is the
        //anchor for the second slide)
        if(index == 2 && slideIndex == 'secondSlide'){
            alert("Second slide loaded");
        }
    }
});
onSlideLeave (anchorLink, index, slideIndex, direction, nextSlideIndex)
This callback is fired once the user leaves an slide to go to another, in the transition to the new slide. Returning false will cancel the move before it takes place.

Parameters:

anchorLink: anchorLink corresponding to the section.
index: index of the section. Starting from 1.
slideIndex: index of the slide. Starting from 0.
direction: takes the values right or left depending on the scrolling direction.
nextSlideIndex: index of the destination slide. Starting from 0.
Example:

$('#fullpage').fullpage({
    onSlideLeave: function( anchorLink, index, slideIndex, direction, nextSlideIndex){
        var leavingSlide = $(this);

        //leaving the first slide of the 2nd Section to the right
        if(index == 2 && slideIndex == 0 && direction == 'right'){
            alert("Leaving the fist slide!!");
        }

        //leaving the 3rd slide of the 2nd Section to the left
        if(index == 2 && slideIndex == 2 && direction == 'left'){
            alert("Going to slide 2! ");
        }
    }
});
Cancelling a move before it takes place
You can cancel a move by returning false on the onSlideLeave callback. Same as when canceling a movement with onLeave.

6.配置

选项

选项 类型 默认值 说明
verticalCentered 字符串 true 内容是否垂直居中
resize 布尔值 false 字体是否随着窗口缩放而缩放
slidesColor 函数 设置背景颜色
anchors 数组 定义锚链接
scrollingSpeed 整数 700 滚动速度,单位为毫秒
easing 字符串 easeInQuart 滚动动画方式
menu 布尔值 false 绑定菜单,设定的相关属性与 anchors 的值对应后,菜单可以控制滚动
navigation 布尔值 false 是否显示项目导航
navigationPosition 字符串 right 项目导航的位置,可选 left 或 right
navigationColor 字符串 #000 项目导航的颜色
navigationTooltips 数组 项目导航的 tip
slidesNavigation 布尔值 false 是否显示左右滑块的项目导航
slidesNavPosition 字符串 bottom 左右滑块的项目导航的位置,可选 top 或 bottom
controlArrowColor 字符串 #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  

方法

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

回调函数

名称 说明
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个参数

到此这篇关于fullpage.js全屏滚动的具体使用方法的文章就介绍到这了,更多相关fullpage.js使用内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: fullpage.js全屏滚动的具体使用方法

本文链接: https://www.lsjlt.com/news/135753.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • fullpage.js全屏滚动的具体使用方法
    1.fullpage.js  下载地址 https://github.com/alvarotrigo/fullPage.js  2.fullPage.js 是一个...
    99+
    2024-04-02
  • fullPage.js和CSS3实现全屏滚动效果的示例分析
    这篇文章主要介绍了fullPage.js和CSS3实现全屏滚动效果的示例分析,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。首先说一下full...
    99+
    2024-04-02
  • 如何使用ES6写全屏滚动插件
    这篇文章主要为大家展示了“如何使用ES6写全屏滚动插件”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“如何使用ES6写全屏滚动插件”这篇文章吧。1)前面的话现在已...
    99+
    2024-04-02
  • numpy.insert()的具体使用方法
    目录1. 参数说明2. 示例2.1. 插入一列,值为标量2.2. 插入一列,值为一维矩阵2.3. 插入多列,值为标量2.4. 输入为一维向量2.5. 输入为矩阵numpy.inser...
    99+
    2023-02-09
    numpy.insert()使用
  • Pythonlistsort方法的具体使用
    目录描述 语法 使用示例 1. 所有参数都省略 2. 指定key参数 3. 指定reverse参数 注意事项 1. sort函数会改变原列表顺序 2. 列表元素类型不一致 3. Py...
    99+
    2024-04-02
  • Python3re.search()方法的具体使用
    re.search()方法扫描整个字符串,并返回第一个成功的匹配。如果匹配失败,则返回None。 与re.match()方法不同,re.match()方法要求必须从字符串的开头进行匹...
    99+
    2024-04-02
  • 微信小程序全屏滚动字幕的实现方法详解
    目录一、实现背景二、实现代码三、滚动速度四、后续优化实现效果 一、实现背景 无意中在某音上看到用手机横屏作为广告屏的视频,大部分都是用第三方软件实现的; 以及在汽车后挡风玻璃放置...
    99+
    2024-04-02
  • Java的invoke方法的具体使用
    如果读一些Java或者相关框架的源码,实际上一定会经常出现invoke方法的调用,在自己或者团队封装框架时,如果有时候弄得不好经常也会报invoke相关的错。 invoke方法是干什...
    99+
    2024-04-02
  • Vue中使用TailwindCSS的具体方法
    目录1. 快速使用2. 快速了解 Tailwind CSS 类3. 在 Tailwind CSS 中使用 flex 布局4. 实现常见的布局5. 实现黑白主题切换6. Tailwin...
    99+
    2023-05-14
    Vue使用Tailwind CSS Vue Tailwind CSS
  • PHP中upload.php的具体使用方法
    这篇文章主要介绍“PHP中upload.php的具体使用方法”,在日常操作中,相信很多人在PHP中upload.php的具体使用方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”PHP中upload.php的...
    99+
    2023-06-17
  • Python中str.format()方法的具体使用
    目录1. 术语说明 2. 简单字段名 2.1 简单字段名的说明 2.2 省略字段名 2.3 数字形式的简单字段名 2.4 变量名形式的简单字段名 2.5 简单字段名的混合使用 2.6...
    99+
    2024-04-02
  • C语言结构体的具体使用方法
    目录初识C语言结构体1.为什么要有结构体2.结构体的定义2.1结构体类型的定义2.2定义结构体普通变量及访问2.3定义结构体指针变量及访问初识C语言结构体 1.为什么要有结构体 (1...
    99+
    2024-04-02
  • 使用css设置滚动条的方法
    这篇文章给大家分享的是有关使用css设置滚动条的方法的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。设置滚动条的方法:1、使用overflow属性设置是否出现滚动条,代码如“overflow:scroll”;2、使...
    99+
    2023-06-06
  • Dev-C++调试方法的具体使用
    目录写在前面具体步骤0. 确定编译器1. 开启调试模式2. 代码调试写在前面 已经弃坑Dev-C++有一段时间了,但作为一款轻量且新手友好的IDE,它往往是入门C/C++以及刷算法题...
    99+
    2024-04-02
  • Linux的iptstate命令具体使用方法
    这篇文章主要介绍“Linux的iptstate命令具体使用方法”,在日常操作中,相信很多人在Linux的iptstate命令具体使用方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux的iptstat...
    99+
    2023-06-28
  • 如何使用HTML和CSS实现一个全屏滚动布局
    随着互联网的发展,页面设计越来越注重用户体验。全屏滚动布局就是一种常用的设计方式,它能够让页面更加吸引人,并且提供了流畅的用户导航体验。如果你想学习如何使用HTML和CSS实现一个全屏滚动布局,本文将为你提供具体的代码示例和实现步骤。在开始...
    99+
    2023-10-21
    CSS html - 滚动布局 - 全屏布局 - 全屏滚动
  • node.js 全局变量的具体使用
    全局对象 所有模块都可以调用 global:表示Node所在的全局环境,类似于浏览器中的window对象。 process:指向Node内置的process模块,允...
    99+
    2024-04-02
  • rsync具体使用方法是什么
    这期内容当中小编将会给大家带来有关rsync具体使用方法是什么,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。rsync是可以实现增量备份的工具。配合任务计划,rsync能实现定时或间隔同步,配合inoti...
    99+
    2023-06-28
  • Gson之toJson和fromJson方法的具体使用
    目录1.toJson()方法是实现从java实体到Json相关对象的方法2.fromJson()方法来实现从Json相关对象到java实体的方法Gson是Google的一个开源项目,...
    99+
    2024-04-02
  • Linux中history命令的具体使用方法
    这篇文章主要介绍“Linux中history命令的具体使用方法”,在日常操作中,相信很多人在Linux中history命令的具体使用方法问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux中history...
    99+
    2023-06-13
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作