Skip to content

Commit 5d70213

Browse files
authored
Merge pull request #121 from ganderzz/feature/fix-safari
fix: unsupported scrollTo() browsers and react storybook
2 parents 158b49c + b0762b2 commit 5d70213

File tree

5 files changed

+16
-10
lines changed

5 files changed

+16
-10
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ yarn-error.log*
88
.cache
99

1010
dist
11+
docs
1112

1213
# Runtime data
1314
pids

.storybook/webpack.config.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
const path = require("path");
22

33
module.exports = ({ config }) => {
4-
config.resolve.extensions.push(".ts", ".tsx");
5-
6-
config.module.rules[0].test = /\.(ts|tsx)$/;
7-
config.module.rules[0].query.presets = ["@babel/preset-env"];
8-
9-
config.module.rules.unshift({
4+
config.module.rules.push({
105
test: /\.(ts|tsx)$/,
116
use: [
127
{
138
loader: require.resolve("ts-loader"),
149
options: {
15-
configFile: "../config/tsconfig.json"
10+
configFile: path.resolve(__dirname, "../config/tsconfig.json")
1611
}
1712
}
1813
]
1914
});
20-
15+
config.resolve.extensions.push(".ts", ".tsx");
2116
return config;
2217
};

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
"@babel/preset-react": "7.0.0",
2626
"@storybook/react": "5.1.9",
2727
"@testing-library/react": "8.0.5",
28-
"all-contributors-cli": "6.8.1",
28+
"@types/react-dom": "^16.8.4",
2929
"@types/jest": "^24.0.13",
3030
"@types/node": "^12.0.4",
3131
"@types/react": "^16.8.19",
32+
"all-contributors-cli": "6.8.1",
3233
"babel-core": "7.0.0-bridge.0",
3334
"babel-jest": "24.8.0",
3435
"babel-loader": "8.0.6",
@@ -115,6 +116,6 @@
115116
}
116117
},
117118
"dependencies": {
118-
"@types/react-dom": "^16.8.4"
119+
"smoothscroll-polyfill": "^0.4.4"
119120
}
120121
}

src/ScrollTo.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
import * as React from "react";
22
import ReactDOM from "react-dom";
3+
import * as smoothscroll from "smoothscroll-polyfill";
4+
5+
// Polyfill scrollTo() in Safari, IE, and Edge
6+
smoothscroll.polyfill();
37

48
interface IContextProps {
59
addScrollArea(id: string, node: unknown);

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9401,6 +9401,11 @@ slice-ansi@^2.1.0:
94019401
astral-regex "^1.0.0"
94029402
is-fullwidth-code-point "^2.0.0"
94039403

9404+
smoothscroll-polyfill@^0.4.4:
9405+
version "0.4.4"
9406+
resolved "https://registry.yarnpkg.com/smoothscroll-polyfill/-/smoothscroll-polyfill-0.4.4.tgz#3a259131dc6930e6ca80003e1cb03b603b69abf8"
9407+
integrity sha512-TK5ZA9U5RqCwMpfoMq/l1mrH0JAR7y7KRvOBx0n2869aLxch+gT9GhN3yUfjiw+d/DiF1mKo14+hd62JyMmoBg==
9408+
94049409
snapdragon-node@^2.0.1:
94059410
version "2.1.1"
94069411
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"

0 commit comments

Comments
 (0)