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

Added AMD support #124

wants to merge 2 commits into from

Conversation

gs-rpal-zz
Copy link

@gs-rpal-zz gs-rpal-zz commented Feb 15, 2017

Added AMD Support (fix #114)

Copy link

@sualko sualko left a comment

Choose a reason for hiding this comment

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

I think we should stick more to the umd template.

(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($);
}
})(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

if (typeof define === 'function' && define.amd) {
return factory($);
} 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.

🥇

@sualko
Copy link

sualko commented Mar 27, 2017

Can you add "fix #114" to the pr description in order to link this pr properly to the issue?

@gs-rpal-zz
Copy link
Author

fix #114

@gs-rpal-zz gs-rpal-zz closed this Mar 27, 2017
@gs-rpal-zz gs-rpal-zz reopened this Mar 27, 2017
@gs-rpal-zz
Copy link
Author

gs-rpal-zz commented Mar 27, 2017 via email

@gcrispyn
Copy link

gcrispyn commented Jun 8, 2017

Hey guys, what about this PR?

I would need it for a project using npm and webpack

@ghost
Copy link

ghost commented Aug 28, 2017

i'm using the branch from @gs-rpal because I need CommonJS support for webpack. I've put the require('jscroll') before the plugin call and jquery.jscroll is included in the bundle source. However, the dependency isn't resolved and i get Uncaught TypeError: $(...).jscroll is not a function. Shouldn't it be compatible with webpack?

@ratson
Copy link

ratson commented Sep 3, 2017

@Dotmagic I managed to have the exact need, released a fork version that you may try it out.
Feel free to report issues.

@ghost
Copy link

ghost commented Sep 5, 2017

@ratson I'm not sure its a good idea to create a fork with almost same name but lower the version to 0.0.2? I think its confusing. @pklauzinski is still active on this project and it looks like he still welcome contributions.

I'm using CommonJS or ES6 imports now, I believe we should enhance the pull request to support all this types. Soon bower will disappear and we are going to manage scripts with yarn/webpack, for that reason I consider this feature essential.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

require/import support
6 participants