Skip to content

Commit eaaeaf1

Browse files
committed
get Rating on Hover #48
1 parent 3e65ad8 commit eaaeaf1

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

dist/react-stars.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,16 @@ var ReactStars = function (_Component) {
9494
halfStar: {
9595
at: Math.floor(props.value),
9696
hidden: this.state.config.half && props.value % 1 < 0.5
97-
}
97+
},
98+
config: _extends({}, this.state.config, {
99+
count: props.count,
100+
size: props.size,
101+
char: props.char,
102+
color1: props.color1,
103+
color2: props.color2,
104+
half: props.half,
105+
edit: props.edit
106+
})
98107
});
99108
}
100109
}, {
@@ -147,6 +156,9 @@ var ReactStars = function (_Component) {
147156
this.setState({
148157
stars: this.getStars(index)
149158
});
159+
160+
this.props.onMouseOver(value);
161+
this.props.onMouseMove(value);
150162
}
151163
}, {
152164
key: 'moreThanHalf',
@@ -173,6 +185,8 @@ var ReactStars = function (_Component) {
173185
this.setState({
174186
stars: this.getStars()
175187
});
188+
189+
this.props.onMouseLeave(value);
176190
}
177191
}, {
178192
key: 'clicked',
@@ -293,7 +307,10 @@ ReactStars.defaultProps = {
293307
color1: 'gray',
294308
color2: '#ffd700',
295309

296-
onChange: function onChange() {}
310+
onChange: function onChange() {},
311+
onMouseLeave: function onMouseLeave() {},
312+
onMouseMove: function onMouseMove() {},
313+
onMouseOver: function onMouseOver() {}
297314
};
298315

299316
exports.default = ReactStars;

src/react-stars.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ class ReactStars extends Component {
130130
this.setState({
131131
stars: this.getStars(index)
132132
})
133+
134+
this.props.onMouseOver(value)
135+
this.props.onMouseMove(value)
133136
}
134137

135138
moreThanHalf(event, size) {
@@ -149,6 +152,8 @@ class ReactStars extends Component {
149152
this.setState({
150153
stars: this.getStars()
151154
})
155+
156+
this.props.onMouseLeave(value)
152157
}
153158

154159
clicked(event) {
@@ -250,7 +255,10 @@ ReactStars.defaultProps = {
250255
color1: 'gray',
251256
color2: '#ffd700',
252257

253-
onChange: () => { }
258+
onChange: () => { },
259+
onMouseLeave: () => { },
260+
onMouseMove: () => { },
261+
onMouseOver: () => { },
254262
};
255263

256264
export default ReactStars

0 commit comments

Comments
 (0)