Closed lookfirst closed 9 years ago
I haven't done much with RequireJS. If I just use a reference to Hammer will that address your issue?
You can't depend on window.Hammer being there, it might be defined as a module. Take a look at how Hammer is setting itself up in the context of a loader and then look for the Hammer object in those places too.
Mind tagging 2.1.1 so that it shows up in bower? =)
Did I not push the tags... whoops. Should be there now.
Thanks for pushing the tag. Unfortunately, your change doesn't work properly. If there is no Hammer on line 330 (as in my case), then javascript fails with 'Hammer is not defined'. You're also assuming that require() is also defined, so that will fail for others who use your project without require().
(Hammer || require('Hammer') || window.Hammer)
The same issue exists for the line above with angular.
Suggestions?
I think you're just going to have to do a bit more work to determine if these things exist or not. I'd start with passing in the strings 'angular' and 'Hammer' and then doing a similar dance to what is at the bottom of the hammer.js
library to actually resolve the locations of these objects.
Yeah... I'll add an issue for v2.1.2.
if (typeof Hammer !== 'undefined')...
Sorry it is such a pain... damn javascript. ;-)
Sometimes I really think they just didn't think anything through.
Check this out. I think it fixes this issue, thought I don't have any RequireJS projects to test on.
https://github.com/RyanMullins/angular-hammer/commit/42d21b093b9ee5bea26e94a023b0c71cc22eaa32
Give it a try and if it works I'll push it as v2.1.2
I use requirejs modules to load hammer. Therefore, hammer does not initialize itself into window.Hammer. Your code depends on window.Hammer. I am sad. :cry: