Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added AMD support #124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions jquery.jscroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@
* @version 2.3.7
* @requires jQuery v1.4.3+
* @preserve
* @Supports AMD pattern
*/
(function($) {
(function($, factory){
'use strict';
if (typeof define === 'function' && define.amd) {
return factory($);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rewrite this line to define(['jquery'], factory);.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah

} else {
window.jScroll = factory($);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really like to make a global variable for jScroll?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. To support the current singleton approach

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is not needed, because it's a jquery plugin and is therefore attached to jquery, see https://github.com/pklauzinski/jscroll/blob/master/jquery.jscroll.js#L214

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥇

}
})(jQuery || null, function($) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery || null is pretty useless, isn't it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do


'use strict';

Expand Down Expand Up @@ -224,4 +232,6 @@
});
};

})(jQuery);
return jScroll;

});