senthilporunan / jRate

Generate SVG based Rating with various customized fancy features. More information @ www.toolitup.com
http://www.toolitup.com/jRate.html
MIT License
66 stars 45 forks source link

Cannot use for simple 1/2/3/4/5 selection #25

Closed DarrenCook closed 8 years ago

DarrenCook commented 8 years ago

The partial star selection, returning a decimal number, is clever, but this is an exotic use-case, and most people want to have 5 stars and get an integer from 1 to 5 (and never allow zero to be a choice). (This is how reviews at Amazon et al work.)

There seems to be no combination of the configuration options to allow this, however.

My first workaround was to use all the defaults, and then in the onSet handler to do:

   function handleRatingChange(rating){
     rating = Math.ceil(rating);
     obj.setRating(rating);
     ...
   }

But the partial stars effect is distracting, so we just want each star to be on or off.

I've tried precision:1, but the star can only be selected by clicking in the right-hand side of it. E.g. clicking in the left hand side of the middle star calls onSet(2) not onSet(3). Clicking the left-hand side of the first star calls onSet(0).

Trying to be explicit about all settings with precision:1,min:1,max:5,count:5,minSelected:1 is weird: mouse-over the first star fills in the first star, and a bit of the second star. Mouseover the middle star fills in part of it. (This is similar to #4, I think.)

senthilporunan commented 8 years ago

Code Fixed and tested. It is working now. Please check and let me know.

DarrenCook commented 8 years ago

Thanks, confirmed it works (with precision:1)