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

Full star with RTL not working correctly #75

Open
ehtelahi opened this issue Feb 1, 2021 · 3 comments
Open

Full star with RTL not working correctly #75

ehtelahi opened this issue Feb 1, 2021 · 3 comments

Comments

@ehtelahi
Copy link

ehtelahi commented Feb 1, 2021

If you set rtl true with full star option selected then If you hover over a star it doesnot fill star until you moved to next star then previous star gets selected.. can you please fix it. Thanks

@YaseenHajajweh
Copy link

@ehtelahi , i found work around ,
search for this codei.rtl&&(g=e-g),parseFloat(g)
and replace it with this :
i.rtl&&(g=e-(g-1)),parseFloat(g)

@YaseenHajajweh
Copy link

@ehtelahi , @prrashi in line 473 in index.js

if (options.rtl) {
      calculatedRating = maxValue - (calculatedRating - 1);
}

@romero-cesar
Copy link

@ehtelahi @prrashi

I suggest modifying the round (value) function, after calculating the value it is verified if the rtl option is active, if it is fullStar and the value is greater than 0; then 1 is subtracted from the value.

value += step - remainder;

 if (isRtl && isFullStar && value > 0) {
      value--;
 }

Full function:

  function round (value) {
  /*
   * Rounds the value of rating if `halfStar` or `fullStar` options are chosen
   */

  var remainder = value%step,
      halfStep = step/2,
      isRtl = options.rtl,
      isHalfStar = options.halfStar,
      isFullStar = options.fullStar;

  if (!isFullStar && !isHalfStar) {

    return value;
  }

  if (isFullStar || (isHalfStar && remainder > halfStep)) {

    value += step - remainder;
    if (isRtl && isFullStar && value > 0) {
      value--;
    }

  } else {

    value = value - remainder;

    if (remainder > 0) {

      value += halfStep;
    }
  }

  return value;
}

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

3 participants