This is a StarRating component which provides a complete set of features based on modern web technologies. The js part is written in typescript and well tested. Nearly all logic depending on the visual state is developed over css3 techniques. The js part
npm install ionic1-star-rating
|
|
|
|
|
|
|
|
|
$ npm install ionic1-star-rating from your console
$ bower install ionic1-star-rating from your console
html
`
Load library as minified js file
`html
`
*Load library as ts module
`typescript
import angularStars = require('ionic1-star-rating/dist/index.js');
`
Inject it into angular
`javascript
angular.module('myApp', ['star-rating'])
`
Use it
`html
`
Component Properties
$3
id: string (Optional)
The html id attribute of the star rating
Default: undefined
`html
`
rating: number (Optional)
The actual star rating value
Default: 0
`html
`
showHalfStars: boolean (Optional)
To show half stars or not
Options: true, false
Default: false
`html
`
numOfStars: number (Optional)
The possible number of stars to choose from
Default: 5
`html
`
label-text: string (Optional)
The label text next to the stars.
Default: undefined
`html
`
labelPosition: starRatingPosition (Optional)
The position of the label
Options: top, right, bottom, left
Default: left
`html
`
space: starRatingStarSpace (Optional)
If the start use the whole space or not.
Options: no, between, around
Default: no
`html
`
size: starRatingSizes (Optional)
The height and width of the stars.
Options: small, medium, large
Default: ok
`html
`
color: starRatingColors (Optional)
Possible color names for the stars.
Options: default, negative, ok, positive
Default: undefined
`html
`
disabled: boolean (Optional)
The click callback is disabled, colors are transparent
Default: false
`html
`
direction: string (Optional)
The direction of the stars and label.
Options: rtl, ltr
Default: rtl
`html
`
readOnly: boolean (Optional)
The click callback is disabled
Default: false
`html
`
speed: starRatingSpeed (Optional)
The duration of the animation in ms.
Options: immediately, noticeable, slow
Default: noticeable
`html
`
starType: starRatingStarTypes (Optional)
The type of start resource to use.
Options: svg, icon, custom-icon
Default: svg
`html
`
getColor: Function (Optional)
Calculation of the color by rating.
Params: rating, numOfStars, staticColor
Return: colorName as string
`html
`
getHalfStarVisible: Function (Optional)
Calculation for adding the "half" class or not, depending on the rating value.
Params: rating
Return: boolean
`html
`
`javascript
function getHalfStarVisible(rating) {
var absDiff = Math.abs(rating % 1);
if(absDiff == 0.1) {
return false;
}
return absDiff > 0;
}
`
$3
onClick: Function (Optional)
Callback function for star click event
Params: $event
`html
`
`javascript
function onClick($event) {
parent.clickCount = parent.clickCount + 1;
}
`
onRatingChange: Function (Optional)
Callback function for rating update event
Params: $event
`html
`
`javascript
function onRatingChange($event) {
parent.rating = $event.rating;
}
``