Angular implementation of scrollReveal.js
1. Installation
bower install --save ngScrollReveal
Load scripts:
<script type="text/javascript" src="bower_components/scrollreveal/dist/scrollreveal.js"></script> <script type="text/javascript" src="bower_components/ngScrollReveal/ngScrollReveal.min.js"></script>
and remember to add the module as a dependency:
angular.module('myModule', ['ngScrollReveal']);
2. Usage:
Two use cases are provided:
-
Service: the client is provided of a wrapper of the original library. Inject it in your component and you're ready to go. you can refer to the original doc for the list of available api.
angular.module('myModule') .controller('myCtrl', function(ScrollReveal){ ScrollReveal.reveal('.myClass', {duration: 300}); )} })
-
Directive: using it as a directive is much more powerful, you simple have to decorate your DOM element with the directive
ng-scroll-reveal
passing an object representing the options. In addition the user have the chance to execute a sequence of animation (adding a field 'sequence' to the above object)A basic usage:
options= { origin: 'top', duration: 300 //ms }
<div id="idTest" ng-scroll-reveal="options">Hello</div>
Advanced Usage with sequenced animations:
optionsSequence = { origin: 'top', duration: 300, sequence: { selector: 'myChildSelector', //optional field, if not specified all the DIRECT children will be animated interval: 300 } }
<div ng-scroll-reveal="optionsSequence"> <div class="myChildSelector">Hello</div> <div class="myChildSelector">Hello</div> <div class="myChildSelector">Hello</div> <div class="myChildSelector">Hello</div> </div>
3. Examples:
- Github page made using the directive here
- here is a link to a plunkr with a list of working examples.
4. Contribution:
Feel free to contribute, any help is really appreciated :)
run with:
gulp
gulp dist (for the minification)
Credit for scrollReveal.js to @jlmakes
5. License:
MIT License
Copyright (c) 2017 kinotto
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.