Add AMD support.
This commit is contained in:
parent
7a8b47179c
commit
11997131f4
@ -4,7 +4,8 @@
|
||||
"browser": true
|
||||
},
|
||||
"globals": {
|
||||
"$": true
|
||||
"$": true,
|
||||
"define": true
|
||||
},
|
||||
"rules" : {
|
||||
"quotes": false,
|
||||
|
@ -5,7 +5,13 @@
|
||||
|
||||
var ps = require('../main');
|
||||
|
||||
window.PerfectScrollbar = ps;
|
||||
if (typeof window.Ps === 'undefined') {
|
||||
window.Ps = ps;
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD
|
||||
define(ps);
|
||||
} else {
|
||||
// Add to a global object.
|
||||
window.PerfectScrollbar = ps;
|
||||
if (typeof window.Ps === 'undefined') {
|
||||
window.Ps = ps;
|
||||
}
|
||||
}
|
||||
|
11
src/js/adaptor/jquery.js
vendored
11
src/js/adaptor/jquery.js
vendored
@ -33,9 +33,14 @@ function mountJQuery(jQuery) {
|
||||
};
|
||||
}
|
||||
|
||||
var jq = window.jQuery ? window.jQuery : window.$;
|
||||
if (typeof jq !== 'undefined') {
|
||||
mountJQuery(jq);
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], mountJQuery);
|
||||
} else {
|
||||
var jq = window.jQuery ? window.jQuery : window.$;
|
||||
if (typeof jq !== 'undefined') {
|
||||
mountJQuery(jq);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = mountJQuery;
|
||||
|
Loading…
Reference in New Issue
Block a user