Skip to content

Commit dbd9e7e

Browse files
committed
Initial commit
0 parents  commit dbd9e7e

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bower_components

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
angular-sticky-kit
2+
================
3+
4+
AngularJS directive for [Sticky-Kit](http://leafo.net/sticky-kit/) - A jQuery plugin for making smart sticky elements.
5+
6+
7+
Installation (via Bower):
8+
-------------------------
9+
```shell
10+
$ bower install angular-sticky-kit
11+
```
12+
13+
Usage:
14+
------
15+
Download and include `angular-sticky-kit.js` together with `jquery.js` and `jquery.sticky-kit.js`.
16+
17+
```html
18+
<script type="text/javascript" src="path/to/jquery.js"></script>
19+
<script type="text/javascript" src="path/to/jquery.sticky-kit.js"></script>
20+
<script type="text/javascript" src="path/to/angular-sticky-kit.js"></script>
21+
```
22+
23+
Add "angular-sticky-kit" to your app's dependencies
24+
```javascript
25+
angular.module("myApp", ["angular-sticky-kit"]);
26+
```
27+
28+
Use the directive as an attribute with optional settings as value.
29+
30+
```html
31+
<div sticky-kit="options"></div>
32+
```
33+
34+
Available options can be found over at the [Sticky-Kit reference](http://leafo.net/sticky-kit/#reference).

angular-sticky-kit.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
});

bower.json

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"name": "angular-sticky-kit",
3+
"main": "angular-sticky-kit.js",
4+
"authors": [
5+
"getninjaN <[email protected]>"
6+
],
7+
"description": "AngularJS directive for Sticky-Kit",
8+
"moduleType": [],
9+
"keywords": [
10+
"angular",
11+
"sticky-kit",
12+
"sticky"
13+
],
14+
"license": "MIT",
15+
"homepage": "https://github.com/getninjaN/angular-sticky-kit",
16+
"ignore": [
17+
"**/.*",
18+
"node_modules",
19+
"bower_components",
20+
"test",
21+
"tests"
22+
],
23+
"dependencies": {
24+
"sticky-kit": "~1.1.2"
25+
}
26+
}

0 commit comments

Comments
 (0)