Skip to content
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

disableAfterRate cannot enter a lower rating #53

Open
kevinvanryck opened this issue Nov 28, 2020 · 5 comments
Open

disableAfterRate cannot enter a lower rating #53

kevinvanryck opened this issue Nov 28, 2020 · 5 comments

Comments

@kevinvanryck
Copy link

kevinvanryck commented Nov 28, 2020

When setting disableAfterRate to false, and rating 5/5, then trying to rate 3/5, the rating is set in the callback, but the stars shown on the screen will stay on 5/5, even though the rating changed to 3/5.

This can be tested on the demo page, on the "On hover event" demo, since this one has the disableAfterRate flag disabled
https://nashio.github.io/star-rating-svg/demo/

Can be tested also with this snippet:

$('.rating').starRating('setRating', 5);
$('.rating').starRating('setRating', 3); // does not work
$('.rating').starRating('setRating', 2); // does not work
@gabidabet
Copy link

yeah it work internally but not visually, comment this code and you will be fine :
if (stateClass === 'rated' && endIndex > -1) { // limit to painting only to rated stars, and specific case for half star if (index <= Math.ceil(endIndex) || (index < 1 && endIndex < 0)) { $polygonLeft.attr('style', 'fill:'+ratedColor); } if (index <= endIndex) { $polygonRight.attr('style', 'fill:'+ratedColor); } }

@janones
Copy link

janones commented Feb 1, 2021

Or alter method paintStars() and add these two "Elses"

if (index <= Math.ceil(endIndex) || (index < 1 && endIndex < 0)) { $polygonLeft.attr('style', 'fill:'+ratedColor); } else { //lets you deselect stars $polygonLeft.attr('style', 'stroke-opacity: 0;'); }
if (index <= endIndex) { $polygonRight.attr('style', 'fill:'+ratedColor); } else { //lets you deselect stars $polygonRight.attr('style', 'stroke-opacity: 0;'); }

@matuskm
Copy link

matuskm commented Jun 9, 2021

hello,

where should i put it ?

@janones
Copy link

janones commented Jun 15, 2021

the paintStars() method looks like this after the change:

image

lines with corrections 192 and 200

@nibblebits
Copy link

nibblebits commented Feb 2, 2022

Don't forget to set disableAfterRate to false if your still having this problem after making these changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants