annotate public_html/static/js/implab/sticky.js @ 8:7d92a42f8e18

improved doxygen library
author sergey
date Wed, 14 May 2014 17:28:22 +0400
parents 2d1a0a75fc49
children d9551c7e7101
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
1 define([ 'dojo/on', 'dojo/dom-geometry', 'dojo/dom-style' ], function(on, g,
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
2 css) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
3
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
4 return function(sticker, options) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
5 var dh, pos;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
6
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
7 var pos = g.position(sticker,true);
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
8
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
9 var origLeft = css.get(sticker,'left');
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
10 var left = pos.x + 'px';
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
11
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
12 if (options && options.along) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
13 var along = g.position(options.along,true);
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
14 dh = along.y + along.h - pos.h - pos.y;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
15 } else {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
16 dh = window.scrollMaxY - pos.h - pos.y;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
17 }
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
18
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
19 var fixed = false;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
20
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
21 var stfn = function() {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
22 if(!options || !options.along)
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
23 dh = window.scrollMaxY - pos.h - pos.y;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
24
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
25 if (window.scrollY >= pos.y && window.scrollY <= pos.y + dh) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
26 if (!fixed) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
27 css.set(sticker, { top : 0, left: left, position : 'fixed' });
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
28 fixed = true;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
29 }
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
30 } else {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
31 if (fixed) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
32 fixed = false;
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
33
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
34 css.set(sticker, { position : 'relative', left: origLeft });
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
35
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
36 if (window.scrollY < pos.y) {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
37 css.set(sticker, { top : 'auto' });
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
38 } else {
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
39 css.set(sticker, { top : dh + 'px' });
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
40 }
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
41 }
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
42 }
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
43 };
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
44
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
45 stfn();
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
46
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
47 on(window, 'scroll', stfn );
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
48 };
2d1a0a75fc49 added css, templates
sergey
parents:
diff changeset
49 });