fullPage.js学习笔记1_qiphon3650的博客-程序员宅基地

技术标签: 全屏滚动插件  

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

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

工具下载方法

// With bower
bower install fullpage.js

// With npm
npm install fullpage.js

Optional use of CDN   cdn引用地址

If you prefer to use a CDN to load the needed files, fullPage.js is in CDNJS: https://cdnjs.com/libraries/fullPage.js

上手

首先要有一个div作为所有元素的父级

<div id="fullPage"></div>  这个id不能给body 

< div id = " fullpage " >
< div class = " section " >
first Page
</ div >
< div class = " section " >
sec Page
</ div >
< div class = " section " >
third Page
</ div >
< div class = " section active " >
fouth Page
</ div >
</ div >

如果想要其他的页面首先显示出来,可以给这个页面添加active类名

如果想要在其他页面写一个banner可以这样

< div class = " section active " >
< div class = " slide " > Slide 1 </ div >
< div class = " slide " > Slide 2 </ div >
< div class = " slide " > Slide 3 </ div >
< div class = " slide " > Slide 4 </ div >
</ div >
接下来一个必要的js就写上就可以看看效果了

$(document).ready(function() {
	$('#fullpage').fullpage();
});
更多的扩展参数

$(document).ready(function() {
	$('#fullpage').fullpage({
		//Navigation
		menu: '#menu',
		lockAnchors: false,
		anchors:['firstPage', 'secondPage'],
		navigation: false,
		navigationPosition: 'right',
		navigationTooltips: ['firstSlide', 'secondSlide'],
		showActiveTooltip: false,
		slidesNavigation: false,
		slidesNavPosition: 'bottom',

		//Scrolling
		css3: true,
		scrollingSpeed: 700,
		autoScrolling: true,
		fitToSection: true,
		fitToSectionDelay: 1000,
		scrollBar: false,
		easing: 'easeInOutCubic',
		easingcss3: 'ease',
		loopBottom: false,
		loopTop: false,
		loopHorizontal: true,
		continuousVertical: false,
		continuousHorizontal: false,
		scrollHorizontally: false,
		interlockedSlides: false,
		dragAndMove: false,
		offsetSections: false,
		resetSliders: false,
		fadingEffect: false,
		normalScrollElements: '#element1, .element2',
		scrollOverflow: false,
		scrollOverflowReset: false,
		scrollOverflowOptions: null,
		touchSensitivity: 15,
		normalScrollElementTouchThreshold: 5,
		bigSectionsDestination: null,

		//Accessibility
		keyboardScrolling: true,
		animateAnchor: true,
		recordHistory: true,

		//Design
		controlArrows: true,
		verticalCentered: true,
		sectionsColor : ['#ccc', '#fff'],
		paddingTop: '3em',
		paddingBottom: '10px',
		fixedElements: '#header, .footer',
		responsiveWidth: 0,
		responsiveHeight: 0,
		responsiveSlides: false,
		parallax: false,
		parallaxOptions: {type: 'reveal', percentage: 62, property: 'translate'},

		//Custom selectors
		sectionSelector: '.section',
		slideSelector: '.slide',

		lazyLoading: true,

		//events
		onLeave: function(index, nextIndex, direction){},
		afterLoad: function(anchorLink, index){},
		afterRender: function(){},
		afterResize: function(){},
		afterResponsive: function(isResponsive){},
		afterSlideLoad: function(anchorLink, index, slideAnchor, slideIndex){},
		onSlideLeave: function(anchorLink, index, slideIndex, direction, nextSlideIndex){}
	});
});
如果想添加锚点跳转,可以这样

< ul class = " topanchor " >
< li >< a id = "" href = " #first " >first </ a ></ li >
< li >< a id = "" href = " #second " >second </ a ></ li >
< li >< a id = "" href = " #third " >third </ a ></ li >
< li >< a id = "" href = " #fouth " >fouth </ a ></ li >
</ ul >
< div id = " fullpage " >
< div class = " section " >
first Page
</ div >
< div class = " section " >
sec Page
</ div >
< div class = " section " >
third Page
</ div >
< div class = " section active " >
</div>

js里添加一个这样的属性

$(document).ready(function() {
	$('#fullpage').fullpage({
		anchors:['firstPage', 'secondPage', 'thirdPage']
	});
});
在section里加入属性data-anchor js里不写这个属性也能实现这个效果

< ul class = " topanchor " >
< li >< a id = "" href = " #first " >first </ a ></ li >
< li >< a id = "" href = " #second " >second </ a ></ li >
< li >< a id = "" href = " #third " >third </ a ></ li >
< li >< a id = "" href = " #fouth " >fouth </ a ></ li >
</ ul >
< div id = " fullpage " >
< div data-anchor = " first " class = " section " >
first Page
</ div >
< div data-anchor = " second " class = " section " >
sec Page
</ div >
< div data-anchor = " third " class = " section " >
third Page
</ div >
< div data-anchor = " fouth " class = " section active " >
< div class = " slide " > Slide 1 </ div >
< div class = " slide " > Slide 2 </ div >
< div class = " slide " > Slide 3 </ div >
< div class = " slide " > Slide 4 </ div >
</ div >
</ div >
如果想跳转到制定页面的制定轮播位置可以

< ul id = " menu " ><!--定义菜单 -->
< li data-menuanchor = " first " >< a id = "" href = " #first " >first </ a ></ li >
< li data-menuanchor = " second " >< a id = "" href = " #second " >second </ a ></ li >
< li data-menuanchor = " third " >< a id = "" href = " #third " >third </ a ></ li >
< li data-menuanchor = " fouth " class = " active " >< a id = "" href = " #fouth/4 " >fouth </ a ></ li > <!-- 这里添加了跳转信息 -->
</ ul >
< div id = " fullpage " >
< div data-anchor = " first " class = " section " >
first Page
</ div >
< div data-anchor = " second " class = " section " >
sec Page
</ div >
< div data-anchor = " third " class = " section fp-auto-height-responsive " >
third Page
< img data-src = " http://www.runyuanzs.com/templets/default/images/lianyujiayuan/banner_750.png " >
</ div >
< div data-anchor = " fouth " class = " section " >
< div class = " slide " data-anchor = " slide1 " > Slide 1 </ div >
< div class = " slide " data-anchor = " slide2 " > Slide 2 </ div >
< div class = " slide " data-anchor = " slide3 " > Slide 3 </ div >
< div class = " slide " data-anchor = " slide4 " > Slide 4 </ div >
</ div >
</ div >

切记data-anchor的属性值不能和其他元素的id名一样!!!

如果想要你的section是小的可以添加class

<div class="section">Whole viewport</div>
<div class="section fp-auto-height">Auto height</div>
如果想要section的高度是响应式的可以添加class fp-auto-height-responsive

图片的延时加载也是可以做到的

images, videos and audio都支持延时,如果已经使用了其他的延时工具可以在js中加入lazyLoading: false

<img data-src="image.png">
<video>
	<source data-src="video.webm" type="video/webm" />
	<source data-src="video.mp4" type="video/mp4" />
</video>

Auto play/pause embedded media

媒体标签的自动播放在部分机型上会不能用

Note: the autoplay feature might not work on some mobile devices depending on the OS and browser (i.e. Safari on iOSversion < 10.0).

媒体的自动播放可以使用标签自己的属性,也可以使用data-autoplay

<audio data-autoplay>
	<source src="http://metakoncept.hr/horse.ogg" type="audio/ogg">
</audio>
当桌面换到非媒体板块时可以使用data-keepplaying让媒体保持继续播放

<audio data-keepplaying>
	<source src="http://metakoncept.hr/horse.ogg" type="audio/ogg">
</audio>

State classes added by fullpage.js

Fullpage.js adds multiple classes in different elements to keep a record of the status of the site:

  • active is added the current visible section and slide.
  • active is added to the current menu element (if using the menu option).
  • A class of the form fp-viewing-SECTION-SLIDE is added to the body element of the site. (eg: fp-viewing-secondPage-0) The SECTION and SLIDE parts will be the anchors (or indexes if no anchor is provided) of the current section and slide.
  • fp-responsive is added to the body element when the entering in the responsive mode
  • fp-enabled is added to the html element when fullpage.js is enabled. (and removed when destroyed).
  • fp-destroyed is added to the fullpage.js container when fullPage.js is destroyed.
  • fp-enabled is added to the html element once the libary is initalized.



版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qiphon3650/article/details/76170069

智能推荐

使用 ssm 框架,基本流程-程序员宅基地

题目,写的有点大了,其实就是 对一张表的基本处理,增删改查的基本操作演示。 好了,我们开始了。假如,我们在做一个单表处理,就举例是 学院(某个大学的学院) 吧。 首先,我们分析 学校这样表有哪些属性,分析完后,就可以在数据库中 建 depart 这张表了。 有三个属性:然后要在项目中 做一个 depart Bean 可以使用generate mybais 工具自动生成 depart mo

uva 573 The Snail(模拟)-程序员宅基地

The Snail A snail is at the bottom of a 6-foot well and wants to climb to the top. The snail can climb 3 feet while the sun is up, but slides down 1 foot at night while sleeping. The s

mac mysql语句_mac 使用 mysql_红茶漫山的博客-程序员宅基地

1、启动或关闭(1)系统偏好设置启动或关闭:Launchpad——系统偏好设置——MySQL——Start/Stop MySQL Server终端命令启动或关闭:// 启动:sudo /usr/local/mysql/support-files/mysql.server start// 关闭sudo /usr/local/mysql/support-files/mysql.server stop(..._mac中mysql中运行语句

LeetCode 152. 乘积最大子数组(Python、动态规划)-程序员宅基地

“最大子数组和”的变型题目描述动态规划思路和算法如果我们用 fmax⁡(i)f_{\max}(i)fmax​(i) 来表示以第 iii 个元素结尾的乘积最大子数组的乘积,aaa 表示输入参数 numsnumsnums,那么根据「53. 最大子序和」的经验,我们很容易推导出这样的状态转移方程:fmax⁡(i)=max⁡i=1n{f(i−1)×ai,ai}f_{\max}(i) = \max_{i = 1}^{n} \{ f(i - 1) \times a_i, a_i \}fmax​(i).

Unity3D手机游戏开发的一些笔记-程序员宅基地

发布选项:50页选中Run In Background 即使游戏窗口失去焦点,也会在后台运行.如果在Display Resolution Dialog中选择Disabled,游戏在每次启动时不会显示一个用于设置显示分辨率的窗口。;Icon选择组;可以设置不同大小的图标,如果不指定,他们将会自动调用Default Icon中设置的图标并自动缩放。可能会有锯齿Override

java now_Java Instant now()用法及代码示例-程序员宅基地

在Instant类中,根据传递给它的参数,有两种类型的now()方法。now()Instant类的now()方法用于从系统UTC时钟获取当前时刻。此方法将基于系统UTC时钟返回时刻。用法:public static Instant now()参数:此方法不接受任何参数。返回值:此方法使用系统时钟返回当前时刻以下示例程序旨在说明now()方法:示例1:// Java program to demon..._instant.now()

随便推点

Java并发总结之Java内存模型_数据聪内存读取到缓存时load,read ,write-程序员宅基地

本文主要参考《深入理解Java虚拟机》和《Java并发编程的艺术》对Java内存模型进行简单总结。_数据聪内存读取到缓存时load,read ,write

js代码如何断点debug调试-程序员宅基地

介绍的过程还是以一个测试例子来演示,这样更直观也更容易理解 使用谷歌浏览器打开一个测试的html文件,里面包含简单的js代码(只做演示) 按F12打开网页调试工具,默认打开的是Elements,显示的是网页标签元素,如下图 给js代码打断点,首先需要找到js资源文件,选择Source的tab标签,出现资源文件目录,选择对应的js代码文件 ...

Linux/Unix/Windows?MacOS发展史?一图胜千言!_macos系统和linux系统发行时间-程序员宅基地

文章目录操作系统图示简史_macos系统和linux系统发行时间

请问nj文件如何用html的解析,使用新一代js模板引擎NornJ提升React.js开发体验-程序员宅基地

当前的前端世界中有很多著名的开源javascript模板引擎如Handlebars、Nunjucks、EJS等等,相信很多人对它们都并不陌生。js模板引擎的现状通常来讲,这些js模板引擎项目都有一个共同的特性:只专注渲染字符串(html)早在几年前Backbone等mv*框架流行的时候,js模板引擎遇到了它们的春天,因为Backbone可以支持选配用户自己喜好的模板,并提供了接入方案。但是在新一代...

arduino操作PN532-程序员宅基地

介绍 参考 http://www.arduino.cn/thread-5960-1-1.html 转载于:https://my.oschina.net/surenpi/bl...

对象有哪些继承方式_对象的继承_从人到猿的博客-程序员宅基地

1.原型链2.盗用构造函数3.组合继承4.原型式继承5.寄生式继承6.寄生式组合继承_对象的继承

推荐文章

热门文章

相关标签