|
3 | 3 | <link rel="import" href="../iron-selector/iron-selector.html"> |
4 | 4 |
|
5 | 5 | <!-- |
6 | | -`paper-pager` |
7 | | -A little Material Design page indicator |
| 6 | +`paper-pager` is a Material Design page indicator that adapts to provided variables |
| 7 | +and sets `selected` as user clicks on it. It doesn't require any variable but |
| 8 | +it's higly recommended to provide `itemsCount` (as number) or `items` (as array). |
| 9 | +
|
| 10 | +Example: |
| 11 | +
|
| 12 | + <paper-pager items-count="3" selected="{{selected}}></paper-pager> |
| 13 | +
|
| 14 | +### Styling |
| 15 | +
|
| 16 | +The following custom properties and mixins are available for styling: |
| 17 | +
|
| 18 | +Custom property | Description | Default |
| 19 | +----------------|-------------|---------- |
| 20 | +`--paper-pager-color` | Color of dots | `white` |
| 21 | +`--paper-pager-opacity` | Opacity of not selected dots | `0.7` |
| 22 | +If you quickly need to switch to dark theme you can use `dark` attribute. |
8 | 23 |
|
9 | 24 | @demo demo/index.html |
10 | 25 | --> |
|
65 | 80 | is: 'paper-pager', |
66 | 81 |
|
67 | 82 | properties: { |
68 | | - |
| 83 | + /** |
| 84 | + * Number of items. If you set this leave items empty. |
| 85 | + */ |
69 | 86 | itemsCount: { |
70 | 87 | type: Number, |
71 | 88 | value: 3, |
72 | 89 | observer: '_computeItems' |
73 | 90 | }, |
74 | 91 |
|
| 92 | + /** |
| 93 | + * Takes an array which length will be set as itemsCount. If you set this |
| 94 | + * leave itemsCount empty. |
| 95 | + */ |
75 | 96 | items: { |
76 | 97 | type: Array |
77 | 98 | }, |
78 | 99 |
|
| 100 | + /** |
| 101 | + * Currently selected item's index. |
| 102 | + */ |
79 | 103 | selected: { |
80 | 104 | type: Number, |
81 | 105 | notify: true, |
|
84 | 108 | observer: '_selectedChanged' |
85 | 109 | }, |
86 | 110 |
|
| 111 | + /** |
| 112 | + * Quickly switch to dark theme. |
| 113 | + */ |
87 | 114 | dark: { |
88 | 115 | type: Boolean, |
89 | 116 | value: false, |
|
92 | 119 |
|
93 | 120 | }, |
94 | 121 |
|
95 | | - listeners: { |
96 | | - 'dom-change': '_domRendered' |
| 122 | + attached: function() { |
| 123 | + if (this.selected == 0) { |
| 124 | + this._selectedChanged(this.selected, 2); |
| 125 | + } else { |
| 126 | + this._selectedChanged(this.selected, 0); |
| 127 | + } |
97 | 128 | }, |
98 | 129 |
|
99 | 130 | _onTap: function(e) { |
|
104 | 135 | this.items = new Array(count); |
105 | 136 | }, |
106 | 137 |
|
107 | | - _domRendered: function() { |
108 | | - if (this.selected == 0) { |
109 | | - this._selectedChanged(this.selected, 2); |
110 | | - } else { |
111 | | - this._selectedChanged(this.selected, 0); |
112 | | - } |
113 | | - }, |
114 | | - |
115 | 138 | _selectedChanged: function(selected, lastSelected) { |
116 | 139 | if(selected === undefined || lastSelected === undefined) return; |
117 | 140 | var dot = this.$$('.dot').style; |
|
0 commit comments