I am getting an error when using skrollr and skrollrMenu using RequireJS. This is my main.js file:
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;
},
});
}
});
When I load the page I get the error Uncaught TypeError: Cannot call method 'relativeToAbsolute' of undefined
at this point in the skrollr.menu file:
targetTop = _skrollrInstance.relativeToAbsolute(scrollTarget, 'top', 'top');
Then it is followed by the output of console.log(s)
. Does this mean that skrollr.menu.init
is running before console.log(s)
?