-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathangular-sticky-kit.js
67 lines (66 loc) · 2.35 KB
/
angular-sticky-kit.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
angular.module("angular-sticky-kit", [])
.directive("stickyKit", function() {
return {
restrict: "A",
link: function(scope, element, attributes) {
var customOptions, options, stickyElement, stickyKitAttribute;
stickyKitAttribute = scope.$eval(attributes.stickyKit);
customOptions = typeof stickyKitAttribute == 'object' ? stickyKitAttribute : {};
options = {
sticky_class: "is_stuck",
inner_scrolling: true,
recalc_every: null,
parent: null,
offset_top: 0,
spacer: null,
bottoming: true,
stick: null,
unstick: null,
bottom: null,
unbottom: null,
recalc: null,
detach: null
};
for (var attrname in customOptions) {
options[attrname] = customOptions[attrname];
}
stickyElement = element.stick_in_parent(options);
if (typeof options.stick !== "undefined" && options.stick !== null) {
element.on("sticky_kit:stick", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.stick)
});
}
if (typeof options.unstick !== "undefined" && options.unstick !== null) {
element.on("sticky_kit:unstick", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.unstick)
});
}
if (typeof options.bottom !== "undefined" && options.bottom !== null) {
element.on("sticky_kit:bottom", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.bottom)
});
}
if (typeof options.unbottom !== "undefined" && options.unbottom !== null) {
element.on("sticky_kit:unbottom", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.unbottom)
});
}
if (typeof options.recalc !== "undefined" && options.recalc !== null) {
element.on("sticky_kit:recalc", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.recalc)
});
}
if (typeof options.detach !== "undefined" && options.detach !== null) {
element.on("sticky_kit:detach", function(event) {
var localScope = $(event.target).scope()
localScope.$apply(options.detach)
});
}
}
};
});