OLD | NEW |
(Empty) | |
| 1 |
| 2 |
| 3 Polymer('paper-toggle-button', { |
| 4 |
| 5 /** |
| 6 * Fired when the checked state changes. |
| 7 * |
| 8 * @event change |
| 9 */ |
| 10 |
| 11 /** |
| 12 * Gets or sets the state, `true` is checked and `false` is unchecked. |
| 13 * |
| 14 * @attribute checked |
| 15 * @type boolean |
| 16 * @default false |
| 17 */ |
| 18 checked: false, |
| 19 |
| 20 trackStart: function(e) { |
| 21 this._w = this.$.toggleBar.offsetLeft + this.$.toggleBar.offsetWidth; |
| 22 e.preventTap(); |
| 23 }, |
| 24 |
| 25 trackx: function(e) { |
| 26 this._x = Math.min(this._w, |
| 27 Math.max(0, this.checked ? this._w + e.dx : e.dx)); |
| 28 this.$.toggleRadio.classList.add('dragging'); |
| 29 var s = this.$.toggleRadio.style; |
| 30 s.webkitTransform = s.transform = 'translate3d(' + this._x + 'px,0,0)'; |
| 31 }, |
| 32 |
| 33 trackEnd: function() { |
| 34 var s = this.$.toggleRadio.style; |
| 35 s.webkitTransform = s.transform = null; |
| 36 this.$.toggleRadio.classList.remove('dragging'); |
| 37 this.checked = Math.abs(this._x) > this._w / 2; |
| 38 }, |
| 39 |
| 40 checkedChanged: function() { |
| 41 this.setAttribute('aria-pressed', Boolean(this.checked)); |
| 42 this.fire('change'); |
| 43 } |
| 44 |
| 45 }); |
| 46 |
OLD | NEW |