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

If you vote a high value and then vote a low value, the stars do not change to low value #50

Open
neoburgos opened this issue Aug 21, 2020 · 5 comments

Comments

@neoburgos
Copy link

(The first thing I want to congratulate you on your work)
Example:
disableAfterRate: false
and then vote 4 (for example) and after it you vote 2 (for example), stars color don't change and it fixes on 4, not 2.
You can check it in 'disableAfeterRate' example y your demo web: http://nashio.github.io/star-rating-svg/demo/

@amandachagas
Copy link

Hey @neoburgos have got any ideas on a workaround for this issue?

I'm experiencing the same... I thought i could apply a clean onHover, but there is no clean() function to reset a given rate.

@mcyankee
Copy link

jquery.star-rating-svg... not the min version... around line 195... changed....

          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);
            }
          }

to...

          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);
            }
          } else {
              $polygonLeft.attr('style', 'stroke-opacity: 0');
              $polygonRight.attr('style', 'stroke-opacity: 0');
          }

Hope it helps.

@neoburgos
Copy link
Author

jquery.star-rating-svg... not the min version... around line 195... changed....

          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);
            }
          }

to...

          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);
            }
          } else {
              $polygonLeft.attr('style', 'stroke-opacity: 0');
              $polygonRight.attr('style', 'stroke-opacity: 0');
          }

Hope it helps.

It works great, thanks!

@pow44feet pow44feet mentioned this issue Dec 7, 2020
@sercuu
Copy link

sercuu commented Dec 10, 2020

Great job. thanks!

helloanoop added a commit to helloanoop/star-rating-svg that referenced this issue Sep 11, 2021
@zukucker
Copy link

disableAfterRate is on init true - set it to false an it will work - just for the guys who check this error and the code doesnt work

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