-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathmain.js
44 lines (38 loc) · 1.13 KB
/
main.js
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
41
42
43
44
import $ from 'jquery';
import AsScrollable from './asScrollable';
import info from './info';
const NAMESPACE = 'asScrollable';
const OtherAsScrollable = $.fn.asScrollable;
const jQueryAsScrollable = function(options, ...args) {
if (typeof options === 'string') {
let method = options;
if (/^_/.test(method)) {
return false;
} else if ((/^(get)/.test(method))) {
let instance = this.first().data(NAMESPACE);
if (instance && typeof instance[method] === 'function') {
return instance[method](...args);
}
} else {
return this.each(function() {
let instance = $.data(this, NAMESPACE);
if (instance && typeof instance[method] === 'function') {
instance[method](...args);
}
});
}
}
return this.each(function() {
if (!$(this).data(NAMESPACE)) {
$(this).data(NAMESPACE, new AsScrollable(this, options));
}
});
};
$.fn.asScrollable = jQueryAsScrollable;
$.asScrollable = $.extend({
setDefaults: AsScrollable.setDefaults,
noConflict: function() {
$.fn.asScrollable = OtherAsScrollable;
return jQueryAsScrollable;
}
}, info);