@tramvai/module-autoscroll 1.56.0 → 1.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -9
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Autoscroll
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React component that implements autoscroll to page start or to the anchor on page on SPA-navigations
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The behaviour is similar to the [react-router](https://reacttraining.com/react-router/web/guides/scroll-restoration/scroll-to-tops)
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
First install `@tramvai/module-autoscroll`:
|
|
10
10
|
|
|
11
|
-
```bash
|
|
11
|
+
```bash npm2yarn
|
|
12
12
|
yarn add @tramvai/module-autoscroll
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
And add `AutoscrollModule` to the modules list:
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { createApp } from '@tramvai/core';
|
|
@@ -24,7 +24,17 @@ createApp({
|
|
|
24
24
|
});
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
## Explanation
|
|
28
|
+
|
|
29
|
+
### Behavior
|
|
30
|
+
|
|
31
|
+
`behavior: smooth` is not supported by every browser (e.g. doesn't work in Safari). In this case you can use polyfill `smoothscroll-polyfill` that you should add to your app.
|
|
32
|
+
|
|
33
|
+
## How to
|
|
34
|
+
|
|
35
|
+
### Disable autoscroll for page
|
|
36
|
+
|
|
37
|
+
If you need to disable autoscroll on the specific pages you can specify parameter `navigateState.disableAutoscroll = true` to the `navigate` call:
|
|
28
38
|
|
|
29
39
|
```tsx
|
|
30
40
|
import { useNavigate } from '@tramvai/module-router';
|
|
@@ -38,5 +48,3 @@ function Component() {
|
|
|
38
48
|
return <Button onClick={navigateToWithoutScroll} />;
|
|
39
49
|
}
|
|
40
50
|
```
|
|
41
|
-
|
|
42
|
-
`behavior: smooth` поддерживается не во всех браузерах (например, плавный подскролл не работает в Safari). При необходимости подключите полифил `smoothscroll-polyfill` в свое приложение.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-autoscroll",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.59.0",
|
|
4
4
|
"description": "Компонент с автопрокруткой к началу страницы",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
"build-for-publish": "true"
|
|
19
19
|
},
|
|
20
20
|
"peerDependencies": {
|
|
21
|
-
"@tramvai/core": "1.
|
|
22
|
-
"@tramvai/module-router": "1.
|
|
23
|
-
"@tramvai/tokens-render": "1.
|
|
21
|
+
"@tramvai/core": "1.59.0",
|
|
22
|
+
"@tramvai/module-router": "1.59.0",
|
|
23
|
+
"@tramvai/tokens-render": "1.59.0",
|
|
24
24
|
"@tinkoff/dippy": "0.7.38",
|
|
25
25
|
"react": ">=16.8.0",
|
|
26
26
|
"tslib": "^2.0.3"
|