Skip to content

Commit 56ed528

Browse files
committed
remove npm@2 support
update packages update dependencies
1 parent c8f009e commit 56ed528

File tree

8 files changed

+39
-30
lines changed

8 files changed

+39
-30
lines changed

.eslintrc.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ lib
55

66
# npm debug file
77
npm-debug.log
8+
9+
package-lock.json*

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.eslintignore
2-
.eslintrc.js
32
CHANGELOG.md
43
CONTRIBUTING.md
54
src
5+
package-lock.json*

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
## master (unreleased)
22

3+
## 3.0.0
4+
5+
- Add React 15.5.x support
6+
- Deprecate React 0.14 peer dependencie
7+
38
## 2.2.0
49

510
- Add beforeAnimate/afterAnimate hooks to scroll handler

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ npm install react-scrollchor --save
2525

2626
### Dependencies
2727
* User should provide its own `React` package
28-
* on `npm 2` enviroments, package [fbjs](https://www.npmjs.com/package/fbjs) should be installed too:
29-
```bash
30-
npm install fbjs --save
31-
```
28+
3229

3330
#### `fbjs` package
3431
[fbjs](https://www.npmjs.com/package/fbjs) is a collection of utility libraries created by React Team. It include useful modules like `warning` and `invariant`

package.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,16 @@
77
],
88
"repository": "https://github.com/bySabi/react-scrollchor.git",
99
"main": "lib/scrollchor.js",
10+
"engines": {
11+
"npm": ">=3.0"
12+
},
1013
"scripts": {
1114
"build-npm": "rimraf lib && mkdirp lib && babel src/ -d lib/",
12-
"lint": "eslint . --ext .js,.jsx",
15+
"lint": "semistandard --fix --verbose | snazzy",
1316
"testonly": "echo \"Error: no test specified\" && exit 1",
1417
"test": "npm run lint && npm run testonly",
15-
"prepublish": "npm run build-npm"
18+
"prepare": "npm run build-npm",
19+
"clean-install": "rm -rf node_modules && rm -rf package-lock.json && npm cache clean --force && npm install"
1620
},
1721
"keywords": [
1822
"react",
@@ -24,10 +28,8 @@
2428
"hash",
2529
"animate"
2630
],
27-
"author": "bySabi Files",
28-
"license": "ISC",
2931
"peerDependencies": {
30-
"react": "^15.0.0",
32+
"react": ">=15.0.0",
3133
"fbjs": "*"
3234
},
3335
"devDependencies": {
@@ -38,13 +40,19 @@
3840
"babel-preset-es2015": "6.x.x",
3941
"babel-preset-react": "6.x.x",
4042
"babel-preset-stage-3": "6.x.x",
41-
"eslint": "3.x.x",
42-
"eslint-config-standard-deviation": "1.x.x",
43-
"eslint-modules-standard-deviation": "1.x.x",
43+
"babel-eslint": "7.x.x",
44+
"prettier-eslint-cli": "4.x.x",
45+
"semistandard": "*",
46+
"snazzy": "7.x.x",
4447
"fbjs": "*",
4548
"mkdirp": "*",
4649
"prop-types": "^15.5.8",
4750
"react": "^15.5.4",
4851
"rimraf": "2.x.x"
49-
}
52+
},
53+
"semistandard": {
54+
"parser": "babel-eslint"
55+
},
56+
"author": "bySabi Files",
57+
"license": "ISC",
5058
}

src/scrollchor.jsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
import React from 'react';
2-
import PropTypes from 'prop-types'
2+
import PropTypes from 'prop-types';
33
import warning from 'fbjs/lib/warning';
44
import { getScrollTop, setScrollTop, getOffsetTop } from './utils';
55

66
export default class Scrollchor extends React.Component {
7-
constructor(props) {
7+
constructor (props) {
88
super(props);
99
this._to = props.to && props.to.replace(/^#/, '') || '';
1010
const {
1111
offset = 0, duration = 400, easing = easeOutQuad
1212
} = props.animate || {};
1313
this._animate = { offset, duration, easing };
14-
this._beforeAnimate = props.beforeAnimate || function() {};
15-
this._afterAnimate = props.afterAnimate || function() {};
14+
this._beforeAnimate = props.beforeAnimate || function () {};
15+
this._afterAnimate = props.afterAnimate || function () {};
1616
}
1717

1818
static propTypes = {
@@ -33,30 +33,30 @@ export default class Scrollchor extends React.Component {
3333
this._afterAnimate(event);
3434
}
3535

36-
render() {
36+
render () {
3737
const { to, animate, beforeAnimate, afterAnimate, ...props } = this.props; // eslint-disable-line no-unused-vars
3838
return <a {...props} href={'#' + this._to} onClick={this.handleClick} />;
3939
}
4040
}
4141

42-
function animateScroll(id, animate) {
42+
function animateScroll (id, animate) {
4343
const element = id ? document.getElementById(id) : document.body;
4444
warning(element, `Cannot find element: #${id}`);
4545
scrollTo(element, animate);
4646
}
4747

48-
function scrollTo(element, { offset, duration, easing }) {
48+
function scrollTo (element, { offset, duration, easing }) {
4949
const start = getScrollTop();
5050
const to = getOffsetTop(element) + offset;
5151
const change = to - start;
5252
const increment = 20;
5353

54-
function animate(elapsedTime) {
54+
function animate (elapsedTime) {
5555
const elapsed = elapsedTime + increment;
5656
const position = easing(null, elapsed, start, change, duration);
5757
setScrollTop(position);
5858
if (elapsed < duration) {
59-
setTimeout(function() {
59+
setTimeout(function () {
6060
animate(elapsed);
6161
}, increment);
6262
}
@@ -67,6 +67,6 @@ function scrollTo(element, { offset, duration, easing }) {
6767

6868
// Default easing function
6969
// jQuery easing 'swing'
70-
function easeOutQuad(x, t, b, c, d) {
70+
function easeOutQuad (x, t, b, c, d) {
7171
return -c * (t /= d) * (t - 2) + b;
7272
}

src/utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
export function getScrollTop() {
1+
export function getScrollTop () {
22
// jQuery => $('html, body').scrollTop
33
return document.documentElement.scrollTop || document.body.scrollTop;
44
}
55

6-
export function setScrollTop(position) {
6+
export function setScrollTop (position) {
77
document.documentElement.scrollTop = document.body.scrollTop = position;
88
}
99

10-
export function getOffsetTop(element) {
10+
export function getOffsetTop (element) {
1111
const { top } = element.getBoundingClientRect();
1212
return top + getScrollTop();
1313
}

0 commit comments

Comments
 (0)