it’s a jQuery plugin, and only feature is - pin block (mostly header - h1..) on top of the page when user scroll. is fast, got some options, easy to use.

1
2
3
4
5
6
__ _ ______ _ _____ _____ _ _
/ _|(_) | _ \(_) | _ | / ___| | || |
| |_ _ __ __| | | | _ __ __| | | | _ __ \ `--. ___ _ __ ___ | || |
| _|| |\ \/ /| | | || |\ \ / /| | | || '_ \ `--. \ / __|| '__|/ _ \ | || |
| | | | > < | |/ / | | \ V / \ \_/ /| | | |/\__/ /| (__ | | | (_) || || |
|_| |_|/_/\_\|___/ |_| \_/ \___/ |_| |_|\____/ \___||_| \___/ |_||_|

README


  1. description and demo
  2. requirement
  3. example
  4. contact
  5. license

descrption

very simple jQuery plugin for fixing elements on top\with padding wile scrolling the page.

requirements

jQuery

example:

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
<html>
<!-- ... -->
<head>
<!-- ... -->
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/jquery.fix-div-on-scroll-0.0.3.js"></script>
<script>
$(function(){
$('.title').fixDivOnScroll({
topPadding: 0, //in pixels, if you using fixed-to-top nav-bar or somthing like that
anchorPrefix: 'anchor__', //default id prefix for anchor id
defaultScrollerPrefix: 'scroller__index__', //default pattern for div id, only if div doesn't have an id
zIndexInitial: 110, //initial z-index, by default set 100
fixWidth: true, //if width of element is broke, try set to false
customClass: false, //class for fixed element
role: 'simple', //simple - by default or 'menu' - for menue-like
});
});
</script>
<!-- ... -->
</head>
<body>
<!-- ... -->
<div id="container">
<div id="title">general title here</div>
<div id="text">
<div class="title">simple title</div>
<p>
One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head a
<!-- ... -->
</p>
<div class="title">other simple title</div>
<p>
Drops of rain could be heard hitting the pane, which made him feel quite sad. "How about if I sleep a little bit longer and forget all this nonsense
</p>
<!-- .... -->
</div>
</div>
</body>
</html>

Supported methods:

    init:
        $('.title').fixDivOnScroll({ /* options here */ });

    destroy:
        just remove plugin magic.
        $('.title').fixDivOnScroll('destroy');

    reload:
        simple call destroy and then init, need if number of titles dunamicly changes
        $('.title').fixDivOnScroll('reload',{ /* options here */ })

license

The MIT License (MIT)