12345678910 |
- /**
- * angular-strap
- * @version v2.3.9 - 2016-06-10
- * @link http://mgcrea.github.io/angular-strap
- * @author Olivier Louvignes <olivier@mg-crea.com> (https://github.com/mgcrea)
- * @license MIT License, http://www.opensource.org/licenses/MIT
- */
- 'use strict';angular.module('mgcrea.ngStrap.affix',['mgcrea.ngStrap.helpers.dimensions','mgcrea.ngStrap.helpers.debounce']).provider('$affix',function(){var t=this.defaults={offsetTop:'auto',inlineStyles:!0};this.$get=['$window','debounce','dimensions',function(e,o,n){function i(i,r){function c(t,e,o){var n=a(),i=l();return P>=n?'top':null!==t&&n+t<=e.top?'middle':null!==$&&e.top+o+g>=i-$?'bottom':'middle'}function a(){return h[0]===e?e.pageYOffset:h[0].scrollTop}function l(){return h[0]===e?e.document.body.scrollHeight:h[0].scrollHeight}var u={},p=angular.extend({},t,r),h=p.target,d='affix affix-top affix-bottom',m=!1,g=0,v=0,P=0,$=0,x=null,T=null,b=i.parent();if(p.offsetParent)if(p.offsetParent.match(/^\d+$/))for(var k=0;k<1*p.offsetParent-1;k++)b=b.parent();else b=angular.element(p.offsetParent);return u.init=function(){this.$parseOffsets(),v=n.offset(i[0]).top+g,m=!i[0].style.width,h.on('scroll',this.checkPosition),h.on('click',this.checkPositionWithEventLoop),f.on('resize',this.$debouncedOnResize),this.checkPosition(),this.checkPositionWithEventLoop()},u.destroy=function(){h.off('scroll',this.checkPosition),h.off('click',this.checkPositionWithEventLoop),f.off('resize',this.$debouncedOnResize)},u.checkPositionWithEventLoop=function(){setTimeout(u.checkPosition,1)},u.checkPosition=function(){var t=a(),e=n.offset(i[0]),o=n.height(i[0]),f=c(T,e,o);x!==f&&(x=f,'top'===f?(T=null,m&&i.css('width',''),p.inlineStyles&&(i.css('position',p.offsetParent?'':'relative'),i.css('top',''))):'bottom'===f?(T=p.offsetUnpin?-(1*p.offsetUnpin):e.top-t,m&&i.css('width',''),p.inlineStyles&&(i.css('position',p.offsetParent?'':'relative'),i.css('top',p.offsetParent?'':s[0].offsetHeight-$-o-v+'px'))):(T=null,m&&i.css('width',i[0].offsetWidth+'px'),p.inlineStyles&&(i.css('position','fixed'),i.css('top',g+'px'))),i.removeClass(d).addClass('affix'+('middle'!==f?'-'+f:'')))},u.$onResize=function(){u.$parseOffsets(),u.checkPosition()},u.$debouncedOnResize=o(u.$onResize,50),u.$parseOffsets=function(){var t=i.css('position');p.inlineStyles&&i.css('position',p.offsetParent?'':'relative'),p.offsetTop&&('auto'===p.offsetTop&&(p.offsetTop='+0'),p.offsetTop.match(/^[-+]\d+$/)?(g=1*-p.offsetTop,P=p.offsetParent?n.offset(b[0]).top+1*p.offsetTop:n.offset(i[0]).top-n.css(i[0],'marginTop',!0)+1*p.offsetTop):P=1*p.offsetTop),p.offsetBottom&&($=p.offsetParent&&p.offsetBottom.match(/^[-+]\d+$/)?l()-(n.offset(b[0]).top+n.height(b[0]))+1*p.offsetBottom+1:1*p.offsetBottom),p.inlineStyles&&i.css('position',t)},u.init(),u}var s=angular.element(e.document.body),f=angular.element(e);return i}]}).directive('bsAffix',['$affix','$window',function(t,e){return{restrict:'EAC',require:'^?bsAffixTarget',link:function(o,n,i,s){var f={scope:o,target:s?s.$element:angular.element(e)};angular.forEach(['offsetTop','offsetBottom','offsetParent','offsetUnpin','inlineStyles'],function(t){if(angular.isDefined(i[t])){var e=i[t];/true/i.test(e)&&(e=!0),/false/i.test(e)&&(e=!1),f[t]=e}});var r=t(n,f);o.$on('$destroy',function(){r&&r.destroy(),f=null,r=null})}}}]).directive('bsAffixTarget',function(){return{controller:['$element',function(t){this.$element=t}]}});
- //# sourceMappingURL=affix.min.js.map
|