Skip to content

Commit

Permalink
fix(hover color with custom getColor): display color of custom getCol…
Browse files Browse the repository at this point in the history
…or function when hovering

Closes #77
  • Loading branch information
BioPhoton committed Apr 20, 2018
1 parent b03857b commit f00737e
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 27 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions @packaged/angular-star-rating/esm2015/angular-star-rating.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions @packaged/angular-star-rating/esm5/angular-star-rating.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions @packaged/angular-star-rating/esm5/angular-star-rating.js.map

Large diffs are not rendered by default.

Expand Up @@ -121,7 +121,7 @@ export declare class StarRating {
constructor(config: StarRatingConfigService);
svgVisible(): boolean;
interactionPossible(): boolean;
setColor(): void;
setColor(useHoverValue?: boolean): void;
setHalfStarVisible(): void;
getComponentClassNames(): string;
increment(): void;
Expand Down
Expand Up @@ -205,6 +205,7 @@ <h1>Property Bindings</h1>
<div class="col">
<label>&nbsp;</label>
<star-rating
[hoverEnabled]="true"
[getColor]="bindingsForm.get('useCustomGetColor').value ? _getColor : false">
</star-rating>
</div>
Expand Down
Expand Up @@ -120,6 +120,8 @@ export class StarRatingComponent extends StarRating {
}

this.hoverRating = rating ? parseInt(rating.toString(), 10) : 0;
//update calculated Color
this.setColor(true);

//fire onHoverRatingChange event
const $event: HoverRatingChangeEvent = { hoverRating: this.hoverRating };
Expand Down
7 changes: 4 additions & 3 deletions libs/angular-star-rating/src/services/star-rating.ts
Expand Up @@ -389,17 +389,18 @@ export class StarRating {
return !this.readOnly && !this.disabled;
}

setColor(): void {
setColor(useHoverValue = false): void {
//check if custom function is given
const ratingValue = useHoverValue ? this.hoverRating: this.rating;
if (typeof this.getColor === 'function') {
this.color = this.getColor(
this.rating,
ratingValue,
this.numOfStars,
this.staticColor
);
} else {
this.color = StarRatingUtils.getColor(
this.rating,
ratingValue,
this.numOfStars,
this.staticColor
);
Expand Down

0 comments on commit f00737e

Please sign in to comment.