Skip to content

Commit 09f698e

Browse files
committed
restructure react component and add demo page
1 parent 9c0311e commit 09f698e

10 files changed

Lines changed: 8039 additions & 121 deletions

File tree

.babelrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"presets": ["es2015", "react"]
2+
"presets": ["@babel/preset-env", "@babel/preset-react"],
3+
"plugins": ["@babel/plugin-proposal-class-properties"]
34
}

README.md

Lines changed: 35 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,79 @@
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
42

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.
65

7-
![ScreenShot](/example.png)
6+
**[Watch Demo](https://fluse.github.io/react-scroll-bound/)**
87

98
supports react 15.x and 16.x
109

11-
[![npm package](https://nodei.co/npm/react-list-scroll-bound.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/react-list-scroll-bound/)
12-
[![NPM](https://nodei.co/npm-dl/react-list-scroll-bound.png?months=6&height=3)](https://www.npmjs.com/package/react-list-scroll-bound)
13-
14-
## install
10+
## Install
1511

1612
```
17-
> npm install react-list-scroll-bound --save
13+
npm install react-scroll-bound --save
1814
```
1915

20-
## how to use
16+
## Usage
2117

2218
```jsx
2319

24-
<ListScrollBound className="my-list">
20+
import ScrollBound from 'react-scroll-bound'
21+
22+
<ScrollBound>
2523
{this.getListPoints()}
26-
</ListScrollBound>
24+
</ScrollBound>
2725

2826
```
2927

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
3929

30+
```css
31+
.my-class-name {
32+
max-height: 250px;
33+
overflow-y: auto;
34+
}
4035
```
4136

42-
### get events
43-
44-
```jsx
37+
### Change HTML-Tag
4538

46-
let onWheel = function (event) {
47-
console.log(event)
48-
}
39+
default tagName is `<ul>`
4940

50-
let onClick = function (event) {
51-
console.log(event)
52-
}
41+
```jsx
5342

54-
<ListScrollBound onWheel={onWheel} onClick={onClick} className="my-list">
43+
<ScrollBound tagName="div">
5544
{this.getListPoints()}
56-
</ListScrollBound>
45+
</ScrollBound>
5746

5847
```
5948

60-
### set more propTypes
61-
62-
all given properties will set on the given ListScrollBound element, with
63-
64-
`{...this.props}`
49+
### Set properties
6550

66-
so you can set all what you want and need
51+
all attributes and properties will transmitted with `{...this.props}`
6752

6853
```jsx
6954

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+
>
7161
{this.getListPoints()}
72-
</ListScrollBound>
62+
</ScrollBound>
7363

7464
```
7565

76-
### Development
66+
## Development
7767

7868
if you want to add or optimize this component, feel free <3
7969

80-
clone this repository and run install
70+
#### Run Dev Server
8171

8272
```
83-
npm install
73+
npm start
8474
```
8575

86-
and after changes compile es6 to es5
76+
### Compile to ES5
8777

8878
```
8979
npm run compile

0 commit comments

Comments
 (0)