-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Help wanted: Create documentation on requiring Velocity #258
Comments
Documentation is not my strong point. Here you go. Feel free to do with it what you will :) When using browserify to bundle Velocity you i.e. When you run For n.b. When using the shim you will most likely want to use the --exclude or -u option. That way your bundle will work with or without jQuery being available. |
AMD/RequireJS implementation needs to be fixed up a little, see #238. But this is how it should work: (I'm also not so good at documentation.) RequireJS-based project with jQueryConfiguration: requirejs.config({
baseUrl: 'js',
paths: {
jquery: 'vendor/jquery'
},
deps: ['vendor/velocity']
}) Having define(['jquery'], function($) {
$('.foo').velocity({opacity: 0}, {display: 'none'})
}) Or, to use the Velocity utility function: define(['vendor/velocity'], function(velocity) {
velocity(
document.querySelector('.foo'),
{opacity: 0},
{display: 'none'}
)
}) RequireJS-based build without jQueryConfiguration: requirejs.config({
baseUrl: 'js',
paths: {
velocity: 'vendor/velocity-nojquery' // jQuery shim + velocity
}
}) Module example: define(['velocity'], function(velocity) {
velocity(
document.querySelector('.foo'),
{opacity: 0},
{display: 'none'}
)
}) |
Thanks, Luke and Frank. I will get to work on formalizing this. |
I have problems with the velocityui pack. No matter how I configure requirejs it complains that it's loaded BEFORE velocity. |
You're shimming velocity as a dependency of velocity ui? |
Yes. I have to add that it works except when I'm bundling it. |
Then this is a problem in your r.js config. Perhaps your static paths are different then your static URLs? In that case you'll need define all your paths in the r.js config and not load it from requirejs config. We'll close this issue but feel free to post a pen/fiddle with your configs and perhaps I can help you trace it down. @julianshapiro close. |
It worked before updating velocity. After upgrading velocity 0.0.14 -> 0.11.9 and velocity.ui 0.1.0 -> 4.1.3 it broke. I'm using gulp with the gulp-requirejs (2.1.8). plugin. Requirejs > 2.1.10 has a "wrapShim" option which might make velocityui in it's current incarnation work, but I can't update. There are four (!) gulp plugins for that job now, and it took me 3 hours to make that one work. I tried the others which support newer require.js versions but could not make them work. I just wrapped the velocityui file in a define() call, can't afford to lose more time to this. |
And thanks for your efforts of course! :) |
@ydaniv: should I wrap velocity ui in module loading IFFE's? i can put on my to-do list for this week |
@julianshapiro I don't think that's needed. @fab1an see here - as of 2.1.11 you can tell r.js to wrap shimmed deps which have intermediate AMD dependencies of their own. Please give it a try and let us know, if no go I'll research this more thoroughly. |
@ydaniv Like i said above: I can't update to 2.1.11 without breaking my build-system, cause I would have to switch plugins. I wrap it myself for now. |
@fab1an just tested it myself with 2.1.14 and looks like you're right. Every way I try to configure it the |
@fab1an this should be fixed now. i've wrapped velocity ui in a module. thanks for your patience. |
Thank you! |
Browserify/RequireJS, etc. With and without Velocity's jQuery shim.
I know the basics but I feel like someone would know better than me.
I'll then polish it up and add it to the official docs.
The text was updated successfully, but these errors were encountered: