Skip to content

Commit

Permalink
add support to use valid html attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenyz committed Jan 28, 2020
1 parent 739bb38 commit 1d3edc8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ All the callback 'onXXXX' can accept a parameter: the ref to the scrollbar conta
</PerfectScrollbar>
```

#### React.HTMLAttributes
Any attributes defined in [React.HTMLAttributes](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react/index.d.ts#L1689) can be used for the component.

### Methods
The following method can be called by the component ref:
#### updateScroll
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as React from 'react';
import PerfectScrollbar from 'perfect-scrollbar';

export interface ScrollBarProps {
export interface ScrollBarProps extends React.HTMLAttributes {
/**
* class name on container
*/
Expand Down
21 changes: 19 additions & 2 deletions src/scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,29 @@ export default class ScrollBar extends Component {

render() {
const {
children, component, style,
className,
style,
option,
options,
containerRef,
onScrollY,
onScrollX,
onScrollUp,
onScrollDown,
onScrollLeft,
onScrollRight,
onYReachStart,
onYReachEnd,
onXReachStart,
onXReachEnd,
component,
children,
...remainProps
} = this.props;
const Comp = component;

return (
<Comp style={style} ref={this.handleRef}>
<Comp style={style} ref={this.handleRef} {...remainProps}>
{children}
</Comp>
);
Expand Down

0 comments on commit 1d3edc8

Please sign in to comment.