forked from danxexe/jquery.syncscroll
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjquery.syncscroll.js
More file actions
32 lines (30 loc) · 1015 Bytes
/
jquery.syncscroll.js
File metadata and controls
32 lines (30 loc) · 1015 Bytes
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
// Generated by CoffeeScript 1.4.0
(function() {
jQuery.fn.syncScroll = function(elements, options) {
var $;
if (options == null) {
options = {};
}
if (this.length < 1) {
return;
}
$ = jQuery;
return this.on('scroll', function() {
var top;
this.$ = $(this);
top = this.$.scrollTop();
return $(elements).each(function() {
var offset, ratio, _$, _delta, _ref, _ref1, _ref2, _ref3;
_$ = $(this);
offset = (_ref = (_ref1 = typeof options['offset'] === "function" ? options['offset'](_$) : void 0) != null ? _ref1 : options['offset']) != null ? _ref : 0;
ratio = (_ref2 = (_ref3 = typeof options['ratio'] === "function" ? options['ratio'](_$) : void 0) != null ? _ref3 : options['ratio']) != null ? _ref2 : 1;
if (top >= offset) {
_delta = (top - offset) * ratio;
return _$.scrollTop(_delta);
} else {
return _$.scrollTop(0);
}
});
});
};
}).call(this);