|
| 1 | +angular.module("angular-sticky-kit", []) |
| 2 | + |
| 3 | +.directive("stickyKit", function() { |
| 4 | + return { |
| 5 | + restrict: "A", |
| 6 | + link: function(scope, element, attributes) { |
| 7 | + var customOptions, defaultOpts, options, stickyElement, stickyKitAttribute; |
| 8 | + options = {}; |
| 9 | + stickyKitAttribute = scope.$eval(attributes.stickyKit); |
| 10 | + customOptions = Object.isObject(stickyKitAttribute) ? stickyKitAttribute : {}; |
| 11 | + defaultOpts = { |
| 12 | + sticky_class: "is_stuck", |
| 13 | + inner_scrolling: true, |
| 14 | + recalc_every: null, |
| 15 | + parent: null, |
| 16 | + offset_top: 0, |
| 17 | + spacer: null, |
| 18 | + bottoming: true, |
| 19 | + stick: null, |
| 20 | + unstick: null, |
| 21 | + bottom: null, |
| 22 | + unbuttom: null, |
| 23 | + recalc: null, |
| 24 | + detach: null |
| 25 | + }; |
| 26 | + options = Object.merge(defaultOpts, customOptions); |
| 27 | + stickyElement = element.stick_in_parent(options); |
| 28 | + if (typeof stick !== "undefined" && stick !== null) { |
| 29 | + element.on("sticky_kit:stick", stick); |
| 30 | + } |
| 31 | + if (typeof unstick !== "undefined" && unstick !== null) { |
| 32 | + element.on("sticky_kit:unstick", unstick); |
| 33 | + } |
| 34 | + if (typeof bottom !== "undefined" && bottom !== null) { |
| 35 | + element.on("sticky_kit:bottom", bottom); |
| 36 | + } |
| 37 | + if (typeof unbottom !== "undefined" && unbottom !== null) { |
| 38 | + element.on("sticky_kit:unbottom", unbottom); |
| 39 | + } |
| 40 | + if (typeof recalc !== "undefined" && recalc !== null) { |
| 41 | + element.on("sticky_kit:recalc", recalc); |
| 42 | + } |
| 43 | + if (typeof detach !== "undefined" && detach !== null) { |
| 44 | + return element.on("sticky_kit:detach", detach); |
| 45 | + } |
| 46 | + } |
| 47 | + }; |
| 48 | +}); |
0 commit comments