star-rating-svg icon indicating copy to clipboard operation
star-rating-svg copied to clipboard

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

Open neoburgos opened this issue 4 years ago • 5 comments

(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/

neoburgos avatar Aug 21 '20 14:08 neoburgos

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.

amandachagas avatar Aug 25 '20 18:08 amandachagas

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.

mcyankee avatar Aug 30 '20 02:08 mcyankee

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!

neoburgos avatar Aug 31 '20 08:08 neoburgos

Great job. thanks!

sercuu avatar Dec 10 '20 17:12 sercuu

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

zukucker avatar Nov 19 '21 11:11 zukucker