Skip to content

Commit

Permalink
Merge b8b5075 into a4e729e
Browse files Browse the repository at this point in the history
  • Loading branch information
fhenderson committed May 13, 2021
2 parents a4e729e + b8b5075 commit add5610
Show file tree
Hide file tree
Showing 8 changed files with 31,290 additions and 6,008 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -4,3 +4,4 @@
/coverage
*.sublime-project
*.sublime-workspace
.idea
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,6 +1,6 @@
language: node_js
node_js:
- "8.11.1"
- "16.0.0"
before_install:
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.6.0
- export PATH="$HOME/.yarn/bin:$PATH"
Expand Down
2 changes: 1 addition & 1 deletion jest.setup.js
@@ -1,4 +1,4 @@
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
const Adapter = require('enzyme-adapter-react-17-updated');

Enzyme.configure({ adapter: new Adapter() });
24,613 changes: 24,613 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

57 changes: 28 additions & 29 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "react-scroll-into-view-if-needed",
"version": "2.1.8",
"version": "3.0.0",
"description": "A thin component wrapper around scroll-into-view-if-needed",
"main": "dist/umd/index.js",
"module": "dist/es/index.js",
Expand Down Expand Up @@ -28,37 +28,36 @@
},
"peerDependencies": {
"prop-types": ">=15",
"react": ">=16"
"react": ">=17"
},
"dependencies": {},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.4",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/preset-env": "^7.4.4",
"@babel/preset-react": "^7.0.0",
"@commitlint/config-conventional": "^7.6.0",
"@babel/cli": "^7.13.16",
"@babel/core": "^7.14.2",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/preset-env": "^7.14.2",
"@babel/preset-react": "^7.13.13",
"@commitlint/config-conventional": "^12.1.4",
"babel-eslint": "^10.0.1",
"commitlint": "^7.6.1",
"coveralls": "^3.0.3",
"cross-env": "^5.2.0",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.12.1",
"enzyme-to-json": "^3.3.5",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.17.2",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"husky": "^2.2.0",
"jest": "^24.8.0",
"commitlint": "^12.1.4",
"coveralls": "^3.1.0",
"cross-env": "^7.0.3",
"enzyme": "^3.11.0",
"enzyme-adapter-react-17-updated": "^1.0.2",
"enzyme-to-json": "^3.6.2",
"eslint": "^7.26.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-react": "^7.23.2",
"husky": "^6.0.0",
"jest": "^26.6.3",
"prop-types": "^15.7.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"rollup": "^1.11.3",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-commonjs": "^9.3.4",
"rollup-plugin-node-resolve": "^4.2.3",
"scroll-into-view-if-needed": "^2.2.20"
"react": "^17.0.2",
"react-dom": "^17.0.2",
"rollup": "^2.47.0",
"rollup-plugin-babel": "^4.4.0",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^5.2.0",
"scroll-into-view-if-needed": "^2.2.28"
}
}
4 changes: 2 additions & 2 deletions src/__tests__/__snapshots__/index.test.js.snap
@@ -1,12 +1,12 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Render in inactive state, then toggle active state 1`] = `
exports['Render in inactive state, then toggle active state 1'] = `
<div>
<MockChild />
</div>
`;

exports[`Render with no props 1`] = `
exports['Render with no props 1'] = `
<div>
<MockChild />
</div>
Expand Down
95 changes: 47 additions & 48 deletions src/index.js
Expand Up @@ -4,54 +4,6 @@ import PropTypes from 'prop-types';
import scrollIntoViewIfNeeded from 'scroll-into-view-if-needed';

export default class ScrollIntoViewIfNeeded extends PureComponent {
static propTypes = {
active: PropTypes.bool,
children: PropTypes.node.isRequired,
elementType: PropTypes.string,
// this shape should mirror the scroll-into-view-if-needed options
options: PropTypes.shape({
behavior: PropTypes.oneOfType([
PropTypes.oneOf([
'auto',
'smooth',
'instant',
]),
PropTypes.func,
]),
block: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
inline: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
scrollMode: PropTypes.oneOf([
'always',
'if-needed',
]),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element),
PropTypes.func,
]),
skipOverflowHiddenElements: PropTypes.bool,
}),
};

static defaultProps = {
active: true,
elementType: 'div',
options: {
behavior: 'smooth',
scrollMode: 'if-needed',
},
};

constructor() {
super();
this.node = createRef();
Expand Down Expand Up @@ -88,3 +40,50 @@ export default class ScrollIntoViewIfNeeded extends PureComponent {
return createElement(elementType, { ref: this.node, ...wrapperProps }, children);
}
}
ScrollIntoViewIfNeeded.propTypes = {
active: PropTypes.bool,
children: PropTypes.node.isRequired,
elementType: PropTypes.string,
// this shape should mirror the scroll-into-view-if-needed options
options: PropTypes.shape({
behavior: PropTypes.oneOfType([
PropTypes.oneOf([
'auto',
'smooth',
'instant',
]),
PropTypes.func,
]),
block: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
inline: PropTypes.oneOf([
'center',
'end',
'nearest',
'start',
]),
scrollMode: PropTypes.oneOf([
'always',
'if-needed',
]),
boundary: PropTypes.oneOfType([
// eslint-disable-next-line no-undef
PropTypes.instanceOf(Element),
PropTypes.func,
]),
skipOverflowHiddenElements: PropTypes.bool,
}),
};

ScrollIntoViewIfNeeded.defaultProps = {
active: true,
elementType: 'div',
options: {
behavior: 'smooth',
scrollMode: 'if-needed',
},
};

0 comments on commit add5610

Please sign in to comment.