将 Skrollr 和 SkrollrMenu 与 RequireJS 结合使用
Using Skrollr and SkrollrMenu with RequireJS
我在使用 RequireJS 使用 skrollr 和 skrollrMenu 时遇到错误。这是我的主要.js文件:
require.config({
paths: {
jquery: '../bower_components/jquery/jquery',
skrollr: '../bower_components/skrollr/src/skrollr',
skrollrMenu: '../bower_components/skrollr-menu/src/skrollr.menu'
},
shim: {
skrollrMenu: {
deps: ['skrollr']
}
}
});
require(['app', 'jquery', 'skrollr', 'skrollrMenu'], function (app, $) {
'use strict';
window.onload = function() {
var s = skrollr.init();
console.log(s);
// //The options (second parameter) are all optional. The values shown are the default values.
skrollr.menu.init(s, {
//skrollr will smoothly animate to the new position using `animateTo`.
animate: true,
//The easing function to use.
easing: 'sqrt',
//How long the animation should take in ms.
duration: function(currentTop, targetTop) {
//By default, the duration is hardcoded at 500ms.
return 500;
//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;
},
});
}
});
当我加载页面时,我在 skrollr.menu 文件中收到错误Uncaught TypeError: Cannot call method 'relativeToAbsolute' of undefined
:
targetTop = _skrollrInstance.relativeToAbsolute(scrollTarget, 'top', 'top');
然后是console.log(s)
的输出。这是否意味着skrollr.menu.init
在console.log(s)
之前运行?
更新到 skrollr-menu 0.1.6(我猜你运行的是 0.1.5)。
相关文章:
- javascript结合了数组和字典
- 将Firebase与Electron结合使用
- 结合jQuery和jetpack无限滚动
- 将Angular js与taglib结合使用
- 以可优化的方式使用requirejs加载模板
- RequireJS向模块传递配置总是返回undefined
- 将图像上传ajax与表单提交ajax相结合
- PhoneGap/带有RequireJS's的文本插件
- 如何正确地将参数传递给RequireJS回调函数
- 在requirejs中共享实例化对象
- 将语句与jquery相结合,并使用媒体查询来实现返回页首按钮
- What does requirejs.config() do?
- 将broccoliJS与当前使用requireJS的模块化主干应用程序结合使用,我想完全放弃requireJS
- 有可能将SYSTEMJS与REQUIREJS结合起来吗
- 将 Skrollr 和 SkrollrMenu 与 RequireJS 结合使用
- 将闭包编译器的类型安全性与AMD(requirejs)结合在一起的最可靠方法是什么?
- 将 jQuery.load 与 RequireJS 结合使用
- 将嵌套的 Knockout.js 组件与 RequireJs 结合使用
- 将RequireJS与GoogleMaps结合使用
- 如何结合CKEditor在我的应用程序代码中使用RequireJS, grunt和uglify