![]() Var parallaxInstance = new Parallax(scene) Var scene = document.getElementById('scene') 1.3 Run ParallaxAs soon as your DOM is ready and loaded, you can create a new Parallax.js instance, providing your scene element as first parameter. The movement applied to each layer will be multiplied by its depth attribute. ![]() While all other options and parameters are optional, with sane defaults, and can be set programatically, each layer needs a data-depth attribute. You can change this to a custom query selector, but again, we're going with the easiest approach for now: Per default, all direct child elements of the scene will become moving objects, the layers. You're free to identify it by any means you want, but for now, let's use an ID: Of course, when you've installed via npm, and use browserify/babel, you can also simply do:Ĭonst Parallax = require('parallax-js') Create your HTML elementsEach Parallax.js instance needs a container element, the scene. You will then find the source code in node_modules/parallax-js/src/parallax.js and the browserified, babelified, uglified, production-ready version in node_modules/parallax-js/dist/ 1.2 Preparations Include the ScriptIf you use the compiled version, either downloaded from the releases page, or copied from the dist folder, include the script like any other Javascript library:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |