durated/angular-scroll — pull request #51 by pandaiolo (2014-07-11 12:56:06+00:00)
Title: Fixes : jshint, strict mode, jshint globals

I had some trouble using angular-scroll in my project, when things broke after packaging my app in a minified file (including angular-scroll.js)

I realized two things :

* The line `this.$get = function() {` in `helpers.js` would not work when minified, `this` becoming undefined (don't know why)
* The behaviour is the same, non minified, if the file is parsed with `"use strict";` at the beginning of the file

Example output of the tests :

Chrome 35.0.1916 (Mac OS X 10.9.4) service scrollContainerAPI should default to $document FAILED
TypeError: Cannot set property '$get' of undefined
at /Users/pandaiolo/Sites/angular-scroll/src/helpers.js:6:13
at Object.invoke (/Users/pandaiolo/Sites/angular-scroll/bower_components/angular/angular.js:3917:17)
at /Users/pandaiolo/Sites/angular-scroll/bower_components/angular/angular.js:3763:71
at Array.forEach (native)
at forEach (/Users/pandaiolo/Sites/angular-scroll/bower_components/angular/angular.js:325:11)
at Object.createInjector [as injector] (/Users/pandaiolo/Sites/angular-scroll/bower_components/angular/angular.js:376

Other issues found/fixed :

* JSHint complains about some globals : fixed by adding `browser = true` option in gulpfile, and specifying globals in file `helpers.js`
* In Chrome, not defining `offset` when calling `scrollToElement(...)` result in `top` variable equals `NaN` because `Number` + `undefined` = `NaN`. Maybe Chrome-only issue, but breaks everything :-). Fix is to explicitly set `offset` to 0 when undefined

**PR Notes**

* Tests : they all pass, except the "service requestAnimation callback should be called within 100ms" which fails until I raise the timeout to 1sec. I assumed it was my setup that was too slow, and left it as is.