if (e.pageX < leftEdge) {
progress = 0;
} else if (e.pageX >= rightEdge) {
progress = obj.width();
}
var rating = progress * 5 / width;
// меньше половины звезды
rating = rating < 0.5 ? 0 : Math.max(Math.ceil(rating), 1);
$("#rating, #rating-overlay").on('mousemove', function(e) {
let width = $(this).width();
let left = $(this).offset().left;
let goPercentage = (e.clientX - left)/width * 100;
//goPercentage = Math.max(Math.ceil(goPercentage/20)*20, 20);
// меньше половины первой звезды
goPercentage = goPercentage < 10 ? 0 : Math.max(Math.ceil(goPercentage/20)*20, 20);
let startPercentage = 100 - goPercentage;
function constrain(n, min, max) {
return Math.max(Math.min(n, max), min);
}
// не нужно
//if (goPercentage === 0){
//$('.stars__count').text('0.0')
//goPercentage = 20;
//constrain(+$('.stars__count').text(), 1, 5);
//}