Skip to content

Commit b928c45

Browse files
committed
Proper husky cfg;
Improved npmignore; Imprtoved test;
1 parent 80a4c2a commit b928c45

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ tests/
33
examples/
44
.idea/
55
src/
6+
.prettierignore
7+
.prettierrc
68
.travis.yml
79
CODE_OF_CONDUCT.md
810
karma.conf.js

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
"webpack-cli": "^3.1.2",
6868
"webpack-dev-server": "^3.1.9"
6969
},
70+
"husky": {
71+
"hooks": {
72+
"pre-commit": "npm run format && git add .",
73+
"post-commit": "git update-index -g"
74+
}
75+
},
7076
"scripts": {
7177
"build": "rimraf ./dist && babel src -d dist --ignore \"node-modules/**\" --presets \"@babel/preset-react,@babel/preset-env\" --plugins \"@babel/plugin-proposal-class-properties\"",
7278
"push-codacy-coverage": "cat ./coverage/lcov.info | codacy-coverage -p .",
@@ -77,7 +83,6 @@
7783
"test:coverage": "cross-env NODE_ENV=test COVERAGE=true karma start --single-run",
7884
"format": "prettier --write src/**/*.js tests/**/*.js examples/**/*.js",
7985
"format:list": "prettier -l src/**/*.js tests/**/*.js examples/**/*.js",
80-
"precommit": "npm run format && git add",
8186
"prepublishOnly": "npm run test && npm run build"
8287
}
8388
}

src/util/LoopController.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ function LoopControllerClass() {
4848

4949
animationFrameId && cancelAnimationFrame(animationFrameId);
5050
requestAnimationFrame(animationFrameCallback);
51+
52+
return this;
5153
};
5254
/**
5355
* Stop the loop if it is active
@@ -62,6 +64,8 @@ function LoopControllerClass() {
6264

6365
animationFrameId && cancelAnimationFrame(animationFrameId);
6466
animationFrameId = null;
67+
68+
return this;
6569
};
6670

6771
/**

src/util/utilities.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ let scrollbarWidth = null;
1414
* @return {number}
1515
*/
1616
export function getScrollbarWidth() {
17-
if (!isset(document)) {
18-
return 0;
19-
}
20-
2117
if (scrollbarWidth !== null) {
2218
return scrollbarWidth;
2319
}
2420

21+
if (!isset(document)) {
22+
return (scrollbarWidth = 0);
23+
}
24+
2525
let el = document.createElement("div");
2626
el.setAttribute("style", "display:block;position:absolute;width:100px;height:100px;top:-9999px;overflow:scroll;");
2727

tests/LoopController.spec.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ describe("LoopController", () => {
2727
let callCount = spy.callCount * 1;
2828
LoopController.stop();
2929

30+
LoopController.stop(); // 2nd call is just for coverage
31+
3032
setTimeout(() => {
3133
expect(spy.callCount).toEqual(callCount);
3234
done();

0 commit comments

Comments
 (0)