In the Add Sequence.js section of the documentation, we describe how to add Sequence.js and its dependencies to a page the traditional way. If you’d rather, Sequence.js can be loaded via RequireJS.
The following is an example of loading Sequence.js via RequireJS and can be found in tests/themes/amd
.
Add Require.js and a reference to your application to the HTML:
<script src="scripts/require.js" data-main="scripts/app"></script>
In app.js
, add the following:
require.config({
baseUrl: 'scripts',
paths: {
imagesLoaded: 'imagesloaded.pkgd.min',
Hammer: 'hammer.min'
}
});
require(["sequence"], function(sequence) {
var element = document.getElementById("sequence");
var options = {
autoPlay: true
};
var mySequence = sequence(element, options);
});
In config.paths
we’ve pointed requireJS to Sequence.js’ dependencies, imagesLoaded and Hammer. Within the require()
function we then initiate Sequence.js and set its options as per the remainder of the Add Sequence.js documentation.