-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need dynamic stepping or distinction between display increment and usage increment #21
Comments
Thanks for this. We had a similar discussion on the In that same issue I suggested maybe adding a |
That would work if the visual representation properly displayed that initial float-value properly. Thanks for the quick reply! Actually I did try to apply a similar workaround like that other vue-rate-it user:
Also tried mouseover/out, but the events don't seem to trigger at all. |
@franktopel they won't trigger if you place them directly on the component, you will need to wrap them in a separate div and add the event listeners on that instead: <div @mouseenter="setRatingIncrement(1)" @mouseleave="setRatingIncrement(0.01)">
<star-rating v-model="rating" :increment="increment"></star-rating>
</div> You will then need to force Vue to refresh the DOM, by resetting the bound rating value: methods: {
setRatingIncrement(increment) {
this.increment = increment
let currentRating = this.rating
this.rating = 0;
this.$nextTick(() => {
this.rating = currentRating;
});
}
} Here's the JSFIddle to show you that in action: https://jsfiddle.net/2rwpo0mb/ As I say, that's not very convenient, so I will try to get this implemented into the component at some point this week. |
Thanks alot for your quick and detailed response! I'm gonna go with the workaround for the time being. Remember to implement this in a way that won't break existing implementations! |
Implemented in Version 1.5.0 |
Most of today's real life implementations of rating stars are used for double purpose:
This leads to a big problem:
The average rating obviously will rarely be 3 or 4, but rather a floating point number like 3.71 or 4.29. This needs to be displayed properly. For this to display properly it is currently necessary to set an
increment
of0.01
.The user that wants to use the stars to give their own rating usually is supposed to choose between giving either 1, 2, 3, 4 or 5 stars. (this explicitly also means you cannot rate lower than 1). This currently requires to set
increment
to1
.This could be solved by either allowing for a dynamic re-evaluation in case the
increment
value changes, or, even better, differentiating between a config parameter which serves for display purposes only, and another for entry purposes.The text was updated successfully, but these errors were encountered: