Skip to content

Commit b10a61f

Browse files
committed
add ScrollToTop
1 parent c32b0aa commit b10a61f

File tree

5 files changed

+64
-7
lines changed

5 files changed

+64
-7
lines changed

.eslintrc

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,40 @@
44
"browser": true,
55
"node": true,
66
"es6": true,
7-
"mocha": true,
7+
"mocha": true
88
},
99
"plugins": ["react"],
10-
10+
"extends": [
11+
"plugin:react/recommended"
12+
],
13+
// eslint > 2.x
14+
"parserOptions": {
15+
"ecmaFeatures": {
16+
"arrowFunctions": true,
17+
"binaryLiterals": true,
18+
"blockBindings": true,
19+
"classes": true,
20+
"defaultParams": true,
21+
"destructuring": true,
22+
"forOf": true,
23+
"generators": true,
24+
"modules": true,
25+
"objectLiteralComputedProperties": true,
26+
"objectLiteralDuplicateProperties": true,
27+
"objectLiteralShorthandMethods": true,
28+
"objectLiteralShorthandProperties": true,
29+
"octalLiterals": true,
30+
"regexUFlag": true,
31+
"regexYFlag": true,
32+
"spread": true,
33+
"superInFunctions": true,
34+
"templateStrings": true,
35+
"unicodeCodePointEscapes": true,
36+
"globalReturn": true,
37+
"jsx": true
38+
}
39+
},
40+
// eslint 1.x
1141
"ecmaFeatures": {
1242
"arrowFunctions": true,
1343
"binaryLiterals": true,

src/app/components/backToTop/BackToTop.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class BackToTop extends Component {
4747
return (
4848
<Motion style={{x: spring(showBackButton ? 0 : 120, presets.stiff)}}>
4949
{
50-
({x}) =>
50+
({x}) => (
5151
<BackToTopButton
5252
position={'bottom-right'}
5353
onClick={this.handlesOnBackButtonClick}
@@ -56,6 +56,7 @@ class BackToTop extends Component {
5656
transform: `translate3d(${x}px, 0, 0)`
5757
}}
5858
/>
59+
)
5960
}
6061
</Motion>
6162
);

src/app/components/backToTop/backToTopButton/UpIcon.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @flow weak
2-
31
import React from 'react';
42
import PropTypes from 'prop-types';
53

src/app/components/backToTop/lib/smoothScroll.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @flow weak
2-
31
import { isBrowserSide } from '../../../services/universal';
42

53
export const smoothScroll = {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// @flow weak
2+
3+
import React, {
4+
PureComponent
5+
} from 'react';
6+
import PropTypes from 'prop-types';
7+
8+
class ScrollToTop extends PureComponent {
9+
static propTypes = {
10+
children: PropTypes.node,
11+
location: PropTypes.string
12+
};
13+
14+
componentDidUpdate(prevProps) {
15+
if (this.props.location !== prevProps.location) {
16+
window.scrollTo(0, 0);
17+
}
18+
}
19+
20+
render() {
21+
const { children } = this.props;
22+
return (
23+
<div>
24+
{ children }
25+
</div>
26+
);
27+
}
28+
}
29+
30+
export default ScrollToTop;

0 commit comments

Comments
 (0)