[英]Can't change skrollr-menu scroll speed (duration)
我正在尝试在我的网站中实现skrollr-menu。 我想要做的是单击按钮时向下滚动到最底端(我的工作正常。问题是,无论我做什么,我都无法使其慢于500ms。我就像描述中所建议的那样,尝试更改所包含代码中的持续时间,但这是行不通的。无论我做什么,无论是更改jQuery中的持续时间,还是尝试通过类强制执行,它都始终保持500ms 。由于我的页面长约18000像素,因此看起来非常恐怖,该如何更改?
的HTML
<a href="#slide-7" data-menu-top="18000" data-menu-duration="10000"><div class="trigger-scroll left">></div></a>
.....
<section id="slide-7" class="scroll-here">
<div class="hsContainer bottom"></div>
</section>
<!-- Includes -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="parallax/js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
<script src="parallax/js/imagesloaded.js"></script>
<script src="parallax/js/skrollr.js"></script>
<script src="parallax/js/skroller.menu.min.js"></script>
<script src="parallax/js/_main.js"></script>
的JavaScript
skrollr.menu.init(s, {
//skrollr will smoothly animate to the new position using `animateTo`.
animate: true,
//The easing function to use.
easing: 'sqrt',
//Multiply your data-[offset] values so they match those set in skrollr.init
scale: 2,
//How long the animation should take in ms.
duration: function(currentTop, targetTop) {
//By default, the duration is hardcoded at 500ms.
return 10000;
//But you could calculate a value based on the current scroll position (`currentTop`) and the target scroll position (`targetTop`).
//return Math.abs(currentTop - targetTop) * 10;
},
//If you pass a handleLink function you'll disable `data-menu-top` and `data-menu-offset`.
//You are in control where skrollr will scroll to. You get the clicked link as a parameter and are expected to return a number.
handleLink: function(link) {
return 400;//Hardcoding 400 doesn't make much sense.
},
//By default skrollr-menu will only react to links whose href attribute contains a hash and nothing more, e.g. `href="#foo"`.
//If you enable `complexLinks`, skrollr-menu also reacts to absolute and relative URLs which have a hash part.
//The following will all work (if the user is on the correct page):
//http://example.com/currentPage/#foo
//http://example.com/currentDir/currentPage.html?foo=bar#foo
///?foo=bar#foo
complexLinks: false,
//This event is triggered right before we jump/animate to a new hash.
change: function(newHash, newTopPosition) {
//Do stuff
},
//Add hash link (e.g. `#foo`) to URL or not.
updateUrl: false //defaults to `true`.
});
我的问题的答案是..当然是拼写错误。
请注意随附脚本中的文件名。
<script src="parallax/js/skrollr.js"></script>
<script src="parallax/js/skroller.menu.min.js"></script>
<script src="parallax/js/_main.js"></script>
中间脚本的名称中带有意外的“ e”,这不会引起任何错误,但是也没有加载文件,因此JavaScript函数根本无法正常工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.