Pure AngularJS component replicating Twitter Bootstrap's Affix component behavior. The affix behavior enables dynamic pinning of a DOM element during page scrolling when specific conditions are met.
Install with bower,
bower install angular-bootstrap-affix --saveOr download the production version or the development version.
In your web page:
<scriptsrc="bower_components/angular/angular.js"></script><scriptsrc="bower_components/angular-jqlite/dist/angular-jqlite.min.js"></script><scriptsrc="bower_components/angular-bootstrap-affix/dist/angular-bootstrap-affix.min.js"></script><scriptsrc="scripts/app.js"></script>In your app.js:
angular.module('myApp',['mgcrea.bootstrap.affix'])To easily add affix behavior to any element, just add
bs-affixto the element you want to spy on. Then use offsets to define when to toggle the pinning of an element on and off.Check Twitter Bootstrap's Affix docs.
<divclass="iphone" bs-affixdata-offset-top="200" data-offset-bottom="300"><divclass="iphone-content"></div></div>