fullpage.js options笔记2
Options
-
controlArrows
: (defaulttrue
) 轮播是否出现箭头Determines whether to use control arrows for the slides to move right or left. -
verticalCentered
: (defaulttrue
) section中的内容自动居中显示 Vertically centering of the content within sections. When set totrue
, your content will be wrapped by the library. Consider using delegation or load your other scripts in theafterRender
callback. -
scrollingSpeed
: (default700
)滚动时间ms Speed in milliseconds for the scrolling transitions. -
sectionsColor
: (defaultnone
)设置每个section的背景色Define the CSSbackground-color
property for each section. Example:
$('#fullpage').fullpage({
sectionsColor: ['#f2f2f2', '#4BBFC3', '#7BAABE', 'whitesmoke', '#000'],
});
-
anchors
: (default[]
)用于锚点按钮的跳转 Defines the anchor links (#example) to be shown on the URL for each section. Anchors value should be unique. The position of the anchors in the array will define to which sections the anchor is applied. (second position for second section and so on). Using anchors forward and backward navigation will also be possible through the browser. This option also allows users to bookmark a specific section or slide. Be careful! anchors can not have the same value as any ID element on the site (or NAME element for IE). Now anchors can be defined directly in the HTML structure by using the attributedata-anchor
as explained here. -
$('#fullpage').fullpage({ anchors: ['firstPage', 'secondPage', 'thirdPage', 'fourthPage', 'lastPage'] });
-
lockAnchors
: (defaultfalse
) 决定是否使用anchor Determines whether anchors in the URL will have any effect at all in the library. You can still using anchors internally for your own functions and callbacks, but they won't have any effect in the scrolling of the site. Useful if you want to combine fullPage.js with other plugins using anchor in the URL.
Important It is helpful to understand that the values in the anchors
option
array correlate directly to the element with the class of .section
by it's position in the markup.
-
easing
: (defaulteaseInOutCubic
)过渡速度Defines the transition effect to use for the vertical and horizontal scrolling. It requires the filevendors/jquery.easings.min.js
or jQuery UI for using some of its transitions. Other libraries could be used instead. -
easingcss3
: (defaultease
)css3过渡Defines the transition effect to use in case of usingcss3:true
. You can use the pre-defined ones (such aslinear
,ease-out
...) or create your own ones using thecubic-bezier
function. You might want to use Matthew Lein CSS Easing Animation Tool for it. -
loopTop
: (defaultfalse
)当滚动到顶部的时候是否可以继续向上滚动(到最后一屏)Defines whether scrolling up in the first section should scroll to the last one or not. -
loopBottom
: (defaultfalse
)当滚动到底部的时候是否可以继续向下滚动(到第一屏) Defines whether scrolling down in the last section should scroll to the first one or not. -
loopHorizontal
: (defaulttrue
)slider是否可以循环滚动Defines whether horizontal sliders will loop after reaching the last or previous slide or not. -
css3
: (defaulttrue
).页面过渡动画是否使用css3动画Defines whether to use JavaScript or CSS3 transforms to scroll within sections and slides. Useful to speed up the movement in tablet and mobile devices with browsers supporting CSS3. If this option is set totrue
and the browser doesn't support CSS3, a jQuery fallback will be used instead. -
autoScrolling
: (defaulttrue
)为false时整个文档变成滚动条模式Defines whether to use the "automatic" scrolling or the "normal" one. It also has affects the way the sections fit in the browser/device window in tablets and mobile phones. -
fitToSection
: (defaulttrue
)确定是否每个section铺满屏幕Determines whether or not to fit sections to the viewport or not. When set totrue
the current active section will always fill the whole viewport. Otherwise the user will be free to stop in the middle of a section (when ) -
fitToSectionDelay
: (default 1000).fitToSection设置为true时的延迟时间 IffitToSection
is set to true, this delays the fitting by the configured milliseconds. -
scrollBar
: (defaultfalse
)是否显示左侧滚动条Determines whether to use scrollbar for the site or not. In case of using scroll bar, theautoScrolling
functionality will still work as expected. The user will also be free to scroll the site with the scroll bar and fullPage.js will fit the section in the screen when scrolling finishes. -
paddingTop
: (default0
)每个section是否有固定的padding-top用于防止顶部固定栏盖住section内容Defines the top padding for each section with a numerical value and its measure (paddingTop: '10px', paddingTop: '10em'...) Useful in case of using a fixed header. -
paddingBottom
: (default0
)每个section是否有固定的padding-bottom用于防止底部固定栏盖住section内容Defines the bottom padding for each section with a numerical value and its measure (paddingBottom: '10px', paddingBottom: '10em'...). Useful in case of using a fixed footer. -
fixedElements
: (defaultnull
)声明定位元素(测试失败,如有成功的请指正)Defines which elements will be taken off the scrolling structure of the plugin which is necessary when using thecss3
option to keep them fixed. It requires a string with the jQuery selectors for those elements. (For example:fixedElements: '#element1, .element2'
) -
normalScrollElements
: (defaultnull
)在某个元素上时设置取消滚轮滚动时的板块跳转事件If you want to avoid the auto scroll when scrolling over some elements, this is the option you need to use. (useful for maps, scrolling divs etc.) It requires a string with the jQuery selectors for those elements. (For example:normalScrollElements: '#element1, .element2'
). This option should not be applied to any section/slide element itself. -
normalScrollElementTouchThreshold
: (default5
)触摸滚动的临界值(建议值3)Defines the threshold for the number of hops up the html node tree Fullpage will test to see ifnormalScrollElements
is a match to allow scrolling functionality on divs on a touch device. (For example:normalScrollElementTouchThreshold: 3
) -
bigSectionsDestination
: (defaultnull
)当一个section高度大于显示屏时,定义如何显示(top:从顶部开始显示、bottom从底部开始显示、null自动。值为string)Defines how to scroll to a section which size is bigger than the viewport. By default fullPage.js scrolls to the top if you come from a section above the destination one and to the bottom if you come from a section below the destination one. Possible values aretop
,bottom
,null
. -
keyboardScrolling
: (defaulttrue
) 是否支持键盘按下出发滚动效果(方向键支持)Defines if the content can be navigated using the keyboard. -
touchSensitivity
: (default5
)定义滑动多长(触摸设备)可以出发section或slide切换Defines a percentage of the browsers window width/height, and how far a swipe must measure for navigating to the next section / slide -
continuousVertical
: (defaultfalse
)是否垂直循环滚动Defines whether scrolling down in the last section or should scroll down to the first one and if scrolling up in the first section should scroll up to the last one. Not compatible withloopTop
,loopBottom
or any scroll bar present in the site (scrollBar:true
orautoScrolling:false
). -
continuousHorizontal
: (defaultfalse
)是否水平循环滚动(扩展组件功能)(测试未生效) Extension of fullpage.js. Defines whether sliding right in the last slide should slide right to the first one or not, and if scrolling left in the first slide should slide left to the last one or not. Not compatible withloopHorizontal
. Requires fullpage.js >= 2.8.3. -
scrollHorizontally
: (defaultfalse
)定义slider是否支持使用鼠标或触摸板滚动(扩展组件功能) Extension of fullpage.js. Defines whether to slide horizontally within sliders by using the mouse wheel or trackpad. Ideal for story telling`. Requires fullpage.js >= 2.8.3. -
interlockedSlides
: (defaultfalse
) Extension of fullpage.js. 定义是否让一个slider移动时其他的slider是否跟着移动Determines whether moving one horizontal slider will force the sliding of sliders in other section in the same direction. Possible values aretrue
,false
or an array with the interlocked sections. For example[1,3,5]
starting by 1. Requires fullpage.js >= 2.8.3. -
dragAndMove
: (defaultfalse
) Extension of fullpage.js. 是否使用手指或鼠标的点击或拖动(测试未成功)Enables or disables the dragging and flicking of sections and slides by using mouse or fingers. Possible values aretrue
,false
,fingersonly
. Requires fullPage.js >= 2.8.9. -
offsetSections
: (defaultfalse
)Extension of fullpage.js. section缩放(测试失败)Provides a way to use non full screen sections based on percentage. Ideal to show visitors there's more content in the site by showing part of the next or previous section. Requires fullPage.js >= 2.8.8 To define the percentage of each section the attributedata-percentage
must be used. The centering of the section in the viewport can be determined by using a boolean value in the attributedata-centered
(default totrue
if not specified). For example:
<div class="section" data-percentage="80" data-centered="true">
-
resetSliders
: (defaultfalse
). Extension of fullpage.js. 离开当前section后本页的slider是否回到初始状态(测试失败)Defines whether or not to reset every slider after leaving its section. Requires fullpage.js >= 2.8.3. -
fadingEffect
: (defaultfalse
). Extension of fullpage.js. 页面切换是否用fade效果代替scroll效果Defines whether to use a fading effect or not instead of the default scrolling one. Possible values aretrue
,false
,sections
,slides
. It can therefore be applied just vertically or horizontally, or to both at the time. Requires fullpage.js >= 2.8.6. -
animateAnchor
: (defaulttrue
)当在地址栏输入某个section时是否显示动画过渡到对应页面Defines whether the load of the site when given an anchor (#) will scroll with animation to its destination or will directly load on the given section. -
recordHistory
: (defaulttrue
)是否记录历史记录Defines whether to push the state of the site to the browser's history. When set totrue
each section/slide of the site will act as a new page and the back and forward buttons of the browser will scroll the sections/slides to reach the previous or next state of the site. When set tofalse
, the URL will keep changing but will have no effect on the browser's history. This option is automatically turned off when usingautoScrolling:false
. -
menu
: (defaultfalse
)一个导航,可以方便的跳到每个section,当section滚动的时候对应的menu会添加active的类名对应的section中添加data-menuanchor属性A selector can be used to specify the menu to link with the sections. This way the scrolling of the sections will activate the corresponding element in the menu using the classactive
. This won't generate a menu but will just add theactive
class to the element in the given menu with the corresponding anchor links. In order to link the elements of the menu with the sections, an HTML 5 data-tag (data-menuanchor
) will be needed to use with the same anchor links as used within the sections. Example:
<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'
});
Note: the menu element should be placed outside the fullpage wrapper in order to avoid problem when using css3:true
.
Otherwise it will be appended to the body
by the plugin itself.
-
navigation
: (defaultfalse
)导航标识如果是true就会在右侧显示圆点状导航标识If set totrue
, it will show a navigation bar made up of small circles. -
navigationPosition
: (defaultnone
)导航标识位置只能设置左或右It can be set toleft
orright
and defines which position the navigation bar will be shown (if using one). -
navigationTooltips
: (default [])鼠标放在导航圆点上后显示的文字Defines the tooltips to show for the navigation circles in case they are being used. Example:navigationTooltips: ['firstSlide', 'secondSlide']
. You can also define them by using the attributedata-tooltip
in each section if you prefer. -
showActiveTooltip
: (defaultfalse
)滚动到对应的section时对应的导航标识显示提示性的文字Shows a persistent tooltip for the actively viewed section in the vertical navigation. -
slidesNavigation
: (defaultfalse
)section终点slider显示对应的导航标识If set totrue
it will show a navigation bar made up of small circles for each landscape slider on the site. -
slidesNavPosition
: (defaultbottom
)slider的导航标识显示的位置,top或bottomDefines the position for the landscape navigation bar for sliders. Admitstop
andbottom
as values. You may want to modify the CSS styles to determine the distance from the top or bottom as well as any other style such as color. -
scrollOverflow
: (defaultfalse
) (not compatible with IE 8) 当内容的高度超过屏幕的高度的时候是否裁剪掉高出的部分,如果设置成true需要引用scrolloverfllow.js如下defines whether or not to create a scroll for the section/slide in case its content is bigger than the height of it. When set totrue
, your content will be wrapped by the plugin. Consider using delegation or load your other scripts in theafterRender
callback. In case of setting it totrue
, it requires the vendor libraryscrolloverflow.min.js
and it should be loaded before the fullPage.js plugin. For example:
<script type="text/javascript" src="vendors/scrolloverflow.min.js"></script>
<script type="text/javascript" src="jquery.fullPage.js"></script>
In order to prevent fullpage.js from creating the scrollbar in certain sections or slides use the class fp-noscroll
.
For example: <div class="section fp-noscroll">
-
scrollOverflowReset
: (defaultfalse
) Extension of fullpage.js. 当为true时,当滚动出当前section时,这个section的状态将变成最初的状态When set totrue
it scrolls up the content of the section/slide with scroll bar when leaving to another vertical section. This way the section/slide will always show the start of its content even when scrolling from a section under it. -
scrollOverflowOptions
: when using scrollOverflow:true fullpage.js will make use of a forked and modified version of iScroll.js libary. You can customize the scrolling behaviour by providing fullpage.js with the iScroll.js options you want to use. Check its documentation for more info. -
sectionSelector
: (default.section
)为了防止未知错误Defines the jQuery selector used for the plugin sections. It might need to be changed sometimes to avoid problem with other plugins using the same selectors as fullpage.js. -
slideSelector
: (default.slide
)为了防止未知错误Defines the jQuery selector used for the plugin slides. It might need to be changed sometimes to avoid problem with other plugins using the same selectors as fullpage.js. -
responsiveWidth
: (default0
) A normal scroll (autoScrolling:false
) will be used under the defined width in pixels. A classfp-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 width is less than 900 the plugin will scroll like a normal site. -
responsiveHeight
: (default0
) A normal scroll (autoScrolling:false
) will be used under the defined height in pixels. A classfp-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. -
responsiveSlides
: (defaultfalse
) Extension of fullpage.js. When set totrue
slides will be turned into vertical sections when responsive mode is fired. (by using theresponsiveWidth
orresponsiveHeight
options detailed above). Requires fullpage.js >= 2.8.5. -
parallax
: (defaultfalse
) Extension of fullpage.js. ----使用覆盖式显示还是链接式显示---Defines whether or not to use the parallax backgrounds effects on sections / slides. Read more about how to apply the parallax option. -
parallaxOptions
: (default:{ type: 'reveal', percentage: 62, property: 'translate'}
). 设置色差背景的参数 Allows to configure the parameters for the parallax backgrounds effect when using the option parallax:true. Read more about how to apply the parallax option. -
lazyLoading
: (defaulttrue
)延时加载是默认存在的,只需要把对应的媒体文件的src属性改成data-src即可Lazy loading is active by default which means it will lazy load any media element containing the attributedata-src
as detailed in the Lazy Loading docs . If you want to use any other lazy loading library you can disable this fullpage.js feature.
Methods
You can see them in action here 各种的效果看这里
moveSectionUp()
Demo Scrolls one section up:
$.fn.fullpage.moveSectionUp(); 页面向上滚动
moveSectionDown()
Demo Scrolls one section down:
$.fn.fullpage.moveSectionDown(); 页面向下滚动
moveTo(section, slide) 移动到指定的section下的指定的slide(slide的下标从0开始)
Demo Scrolls the page to the given section and slide. The first slide, the visible one by default, will have index 0.
/*Scrolling to the section with the anchor link `firstSlide` and to the 2nd Slide */
$.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) 移动到指定的section下的指定的slide(slide的下标从0开始)没有动画过渡效果
Demo Exactly the same as moveTo
but
in this case it performs the scroll without animation. A direct jump to the destination.
/*Scrolling to the section with the anchor link `firstSlide` and to the 2nd Slide */
$.fn.fullpage.silentMoveTo('firstSlide', 2);
moveSlideRight()slide移动到下一个
Demo Scrolls the horizontal slider of the current section to the next slide:
$.fn.fullpage.moveSlideRight();
moveSlideLeft()slide移动到上一个
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 likedown, 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 likedown, 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 orall
. Ifall
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.对应的section的index(从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.将要离开的section -
nextIndex
: index of the destination section. Starting from 1.目标section -
direction
: it will take the valuesup
ordown
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 用return false可以取消滚动
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()当文档dom建立后执行的函数
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");
}
});
- $(this)指的是section的父级
-
[div#fullpage.fullpage-wrapper, selector: "#fullpage", context: document]
- 0:div#fullpage.fullpage-wrapper
- context:document
- length:1
- selector:"#fullpage"
- __proto__:Object(0)
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
)当fullpage.js的模式在normal和responsive之间变化时执行的函数
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
)
当一个section中的slide加载完毕时执行的函数(只有点击切换一个slide或锚点URL中包含一个slide的锚点时才会执行的函数)
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
)在slide之间切换时才会执行的函数
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 valuesright
orleft
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
.
一分的支持也是爱,谢谢!