-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsFixedsticky.js
33 lines (33 loc) · 1.27 KB
/
psFixedsticky.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
angular.module('psFixedsticky', [])
.directive("fixedsticky", function(){
return {
restrict: 'AC',
scope: {
fixedsticky: '@',
fixedstickyactive: "@"
},
link: function(scope,element,attrs){
var parent = element.parent();
var fixedon = "top";
var defaultPx = {};
if(scope.fixedsticky !== undefined){
if(scope.fixedsticky.toLowerCase() == "top" || scope.fixedsticky.toLowerCase() == "bottom"){
fixedon = scope.fixedsticky.toLowerCase();
}
else fixedon = "top";
}
defaultPx[fixedon] = isNaN(element.css(fixedon)) ? 0 : element.css(fixedon);
if(isNaN(parent.data("stickyStack" + fixedon))) parent.data("stickyStack" + fixedon, defaultPx[fixedon]);
element.css(fixedon,parent.data("stickyStack"+fixedon));
parent.data("stickyStack"+fixedon, parent.data("stickyStack"+fixedon) + element[0].clientHeight);
if("fixedstickyactive" in attrs){
if(eval(scope.fixedstickyactive)){
element.fixedsticky();
}
}
else {
element.fixedsticky();
}
}
};
});