样本的标记:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | < ul id = "nav" > < li class = "current" >< a href = "#section-1" >Section 1</ a ></ li > < li >< a href = "#section-2" >Section 2</ a ></ li > < li >< a href = "#section-3" >Section 3</ a ></ li > </ ul > < div id = "section-1" > < strong >Section 1</ strong > < p >Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</ p > </ div > < div id = "section-2" > < strong >Section 2</ strong > < p >Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</ p > </ div > < div id = "section-3" > < strong >Section 3</ strong > < p >Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</ p > </ div > |
示例默认值:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $( '#nav' ).onePageNav({ currentClass: 'current' , changeHash: false , scrollSpeed: 750, scrollThreshold: 0.5, filter: '' , easing: 'swing' , begin: function () { //I get fired when the animation is starting }, end: function () { //I get fired when the animation is ending }, scrollChange: function ($currentListItem) { //I get fired when you enter a section and I pass the list item of the section } }); |
如果你想要改变当用户单击导航,然后改变changeHash选项为true。
如果你想过滤项目从你的导航然后传入一个选择器过滤选项。
1 2 3 4 5 6 7 8 | < ul id = "nav" > < li class = "current" >< a href = "#section-1" >Section 1</ a ></ li > < li >< a href = "#section-2" >Section 2</ a ></ li > < li >< a href = "#section-3" >Section 3</ a ></ li > < li >< a href = "#section-4" >Section 4</ a ></ li > < li >< a href = "#section-5" >Section 5</ a ></ li > </ ul > |
1 2 3 | $('#nav').onePageNav({ filter: ':not(.external)' }); |
如果你在iOS设备上单击链接导航导致其他链接断掉,你可以通过滚动操作来解决这个问题
1 2 3 4 5 6 7 8 9 | $( '#nav' ).onePageNav({ begin: function () { //Hack so you can click other menu items after the initial click $( 'body' ).append( '<div id="device-dummy" style="height: 1px;"></div>' ); }, end: function () { $( '#device-dummy' ).remove(); } }); |
特别申明:
本站所有资源都是由网友投稿发布,或转载各大下载站,请自行检测软件的完整性!
本站所有资源仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您自己承担!
如有侵权请联系我们删除下架,联系方式:lei1294551502@163.com