|
1 | | -# react-list-scroll-bound |
2 | | -prevent body scrolling on list bottom or top end. |
3 | | -Brings a better control for user and increase use experience. |
| 1 | +# react-scroll-bound |
4 | 2 |
|
5 | | -## example |
| 3 | +prevent scrolling on parent element if list reach end or start |
| 4 | +Brings a better control for user and increase use experience. |
6 | 5 |
|
7 | | - |
| 6 | +**[Watch Demo](https://fluse.github.io/react-scroll-bound/)** |
8 | 7 |
|
9 | 8 | supports react 15.x and 16.x |
10 | 9 |
|
11 | | -[](https://nodei.co/npm/react-list-scroll-bound/) |
12 | | -[](https://www.npmjs.com/package/react-list-scroll-bound) |
13 | | - |
14 | | -## install |
| 10 | +## Install |
15 | 11 |
|
16 | 12 | ``` |
17 | | -> npm install react-list-scroll-bound --save |
| 13 | +npm install react-scroll-bound --save |
18 | 14 | ``` |
19 | 15 |
|
20 | | -## how to use |
| 16 | +## Usage |
21 | 17 |
|
22 | 18 | ```jsx |
23 | 19 |
|
24 | | -<ListScrollBound className="my-list"> |
| 20 | +import ScrollBound from 'react-scroll-bound' |
| 21 | + |
| 22 | +<ScrollBound> |
25 | 23 | {this.getListPoints()} |
26 | | -</ListScrollBound> |
| 24 | +</ScrollBound> |
27 | 25 |
|
28 | 26 | ``` |
29 | 27 |
|
30 | | -### set html tag |
31 | | - |
32 | | -default tagName is `<ul>` |
33 | | - |
34 | | -```jsx |
35 | | - |
36 | | -<ListScrollBound tagName="div" className="my-list"> |
37 | | - {this.getListPoints()} |
38 | | -</ListScrollBound> |
| 28 | +Set css for element overflow scroll |
39 | 29 |
|
| 30 | +```css |
| 31 | +.my-class-name { |
| 32 | + max-height: 250px; |
| 33 | + overflow-y: auto; |
| 34 | +} |
40 | 35 | ``` |
41 | 36 |
|
42 | | -### get events |
43 | | - |
44 | | -```jsx |
| 37 | +### Change HTML-Tag |
45 | 38 |
|
46 | | -let onWheel = function (event) { |
47 | | - console.log(event) |
48 | | -} |
| 39 | +default tagName is `<ul>` |
49 | 40 |
|
50 | | -let onClick = function (event) { |
51 | | - console.log(event) |
52 | | -} |
| 41 | +```jsx |
53 | 42 |
|
54 | | -<ListScrollBound onWheel={onWheel} onClick={onClick} className="my-list"> |
| 43 | +<ScrollBound tagName="div"> |
55 | 44 | {this.getListPoints()} |
56 | | -</ListScrollBound> |
| 45 | +</ScrollBound> |
57 | 46 |
|
58 | 47 | ``` |
59 | 48 |
|
60 | | -### set more propTypes |
61 | | - |
62 | | -all given properties will set on the given ListScrollBound element, with |
63 | | - |
64 | | -`{...this.props}` |
| 49 | +### Set properties |
65 | 50 |
|
66 | | -so you can set all what you want and need |
| 51 | +all attributes and properties will transmitted with `{...this.props}` |
67 | 52 |
|
68 | 53 | ```jsx |
69 | 54 |
|
70 | | -<ListScrollBound tagName="div" className="my-list" onChange onClick> |
| 55 | +<ScrollBound |
| 56 | + id="name" |
| 57 | + onWheel={onWheel} |
| 58 | + onClick={onClick} |
| 59 | + className="my-list" |
| 60 | +> |
71 | 61 | {this.getListPoints()} |
72 | | -</ListScrollBound> |
| 62 | +</ScrollBound> |
73 | 63 |
|
74 | 64 | ``` |
75 | 65 |
|
76 | | -### Development |
| 66 | +## Development |
77 | 67 |
|
78 | 68 | if you want to add or optimize this component, feel free <3 |
79 | 69 |
|
80 | | -clone this repository and run install |
| 70 | +#### Run Dev Server |
81 | 71 |
|
82 | 72 | ``` |
83 | | -npm install |
| 73 | +npm start |
84 | 74 | ``` |
85 | 75 |
|
86 | | -and after changes compile es6 to es5 |
| 76 | +### Compile to ES5 |
87 | 77 |
|
88 | 78 | ``` |
89 | 79 | npm run compile |
|
0 commit comments