Skip to content

Commit

Permalink
get Rating on Hover #48
Browse files Browse the repository at this point in the history
  • Loading branch information
anatolyevych committed Jul 30, 2019
1 parent 3e65ad8 commit eaaeaf1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
21 changes: 19 additions & 2 deletions dist/react-stars.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,16 @@ var ReactStars = function (_Component) {
halfStar: {
at: Math.floor(props.value),
hidden: this.state.config.half && props.value % 1 < 0.5
}
},
config: _extends({}, this.state.config, {
count: props.count,
size: props.size,
char: props.char,
color1: props.color1,
color2: props.color2,
half: props.half,
edit: props.edit
})
});
}
}, {
Expand Down Expand Up @@ -147,6 +156,9 @@ var ReactStars = function (_Component) {
this.setState({
stars: this.getStars(index)
});

this.props.onMouseOver(value);
this.props.onMouseMove(value);
}
}, {
key: 'moreThanHalf',
Expand All @@ -173,6 +185,8 @@ var ReactStars = function (_Component) {
this.setState({
stars: this.getStars()
});

this.props.onMouseLeave(value);
}
}, {
key: 'clicked',
Expand Down Expand Up @@ -293,7 +307,10 @@ ReactStars.defaultProps = {
color1: 'gray',
color2: '#ffd700',

onChange: function onChange() {}
onChange: function onChange() {},
onMouseLeave: function onMouseLeave() {},
onMouseMove: function onMouseMove() {},
onMouseOver: function onMouseOver() {}
};

exports.default = ReactStars;
10 changes: 9 additions & 1 deletion src/react-stars.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ class ReactStars extends Component {
this.setState({
stars: this.getStars(index)
})

this.props.onMouseOver(value)
this.props.onMouseMove(value)
}

moreThanHalf(event, size) {
Expand All @@ -149,6 +152,8 @@ class ReactStars extends Component {
this.setState({
stars: this.getStars()
})

this.props.onMouseLeave(value)
}

clicked(event) {
Expand Down Expand Up @@ -250,7 +255,10 @@ ReactStars.defaultProps = {
color1: 'gray',
color2: '#ffd700',

onChange: () => { }
onChange: () => { },
onMouseLeave: () => { },
onMouseMove: () => { },
onMouseOver: () => { },
};

export default ReactStars

0 comments on commit eaaeaf1

Please sign in to comment.