Skip to content

Commit e5b5c8c

Browse files
committed
Merge pull request #264 from xqwzts/node-nwjs-support
nwjs/Browserify Support
2 parents 9e2b329 + d6b0199 commit e5b5c8c

File tree

3 files changed

+27
-11
lines changed

3 files changed

+27
-11
lines changed

jquery.mCustomScrollbar.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,27 @@ the production-ready jquery.mCustomScrollbar.concat.min.js which contains the pl
3636
and dependencies (minified).
3737
*/
3838

39-
;(function($,window,document){
39+
(function (factory) {
40+
if(typeof module !== 'undefined' && module.exports) {
41+
module.exports = factory;
42+
} else {
43+
factory(jQuery, window, document);
44+
}
45+
}(function($){
4046

4147
(function(init){
4248
var _rjs=typeof define==="function" && define.amd, /* RequireJS */
49+
_njs=typeof module !== 'undefined' && module.exports, /* NodeJS */
4350
_dlp=("https:"==document.location.protocol) ? "https:" : "http:", /* location protocol */
4451
_url="cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.12/jquery.mousewheel.min.js";
4552
if(!_rjs){
46-
/* load jquery-mousewheel plugin (via CDN) if it's not present or not loaded via RequireJS
47-
(works when mCustomScrollbar fn is called on window load) */
48-
$.event.special.mousewheel || $("head").append(decodeURI("%3Cscript src="+_dlp+"//"+_url+"%3E%3C/script%3E"));
53+
if (_njs) {
54+
require("jquery-mousewheel")($);
55+
} else {
56+
/* load jquery-mousewheel plugin (via CDN) if it's not present or not loaded via RequireJS
57+
(works when mCustomScrollbar fn is called on window load) */
58+
$.event.special.mousewheel || $("head").append(decodeURI("%3Cscript src="+_dlp+"//"+_url+"%3E%3C/script%3E"));
59+
}
4960
}
5061
init();
5162
}(function(){
@@ -2279,4 +2290,4 @@ and dependencies (minified).
22792290

22802291
});
22812292

2282-
}))}(jQuery,window,document));
2293+
}))}));

package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,7 @@
55
"description": "Highly customizable custom scrollbar jQuery plugin, featuring vertical/horizontal scrollbars, scrolling momentum, mouse-wheel, keyboard and touch support user defined callbacks etc.",
66
"license": "MIT",
77
"homepage": "http://manos.malihu.gr/jquery-custom-content-scroller",
8-
"main": [
9-
"./jquery.mCustomScrollbar.js",
10-
"./jquery.mCustomScrollbar.css",
11-
"./mCSB_buttons.png"
12-
],
8+
"main": "./jquery.mCustomScrollbar.js",
139
"repository": {
1410
"type": "git",
1511
"url": "https://github.com/malihu/malihu-custom-scrollbar-plugin.git"
@@ -31,7 +27,10 @@
3127
"jam": {
3228
"dependencies": {
3329
"jquery": ">=1.6",
34-
"jquery-mousewheel": ">=3.0.6"
30+
"jquery-mousewheel": ">=3.0.6"
3531
}
32+
},
33+
"dependencies": {
34+
"jquery-mousewheel": ">=3.0.6"
3635
}
3736
}

readme.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ npm: `npm install malihu-custom-scrollbar-plugin`
2323

2424
`$(selector).mCustomScrollbar();`
2525

26+
###### Using with [Browserify](http://browserify.org/)
27+
28+
var $ = require('jquery');
29+
require('malihu-custom-scrollbar-plugin')($);
30+
31+
2632
#### For more information
2733

2834
* [Plugin homepage and documentation](http://manos.malihu.gr/jquery-custom-content-scroller)

0 commit comments

Comments
 (0)