3 is
: 'paper-toggle-button',
6 Polymer
.PaperInkyFocusBehavior
11 'aria-pressed': 'false',
17 * Fired when the checked state changes due to user interaction.
22 * Fired when the checked state changes.
27 * Gets or sets the state, `true` is checked and `false` is unchecked.
36 reflectToAttribute
: true,
38 observer
: '_checkedChanged'
42 * If true, the button toggles the active state with each tap or press
52 reflectToAttribute
: true
64 // button-behavior hook
65 _buttonStateChanged: function() {
70 this.checked
= this.active
;
74 _checkedChanged: function(checked
) {
75 this.active
= this.checked
;
76 this.fire('iron-change');
79 _ontrack: function(event
) {
80 var track
= event
.detail
;
81 if (track
.state
=== 'start') {
82 this._trackStart(track
);
83 } else if (track
.state
=== 'track') {
84 this._trackMove(track
);
85 } else if (track
.state
=== 'end') {
86 this._trackEnd(track
);
90 _trackStart: function(track
) {
91 this._width
= this.$.toggleBar
.offsetWidth
/ 2;
93 * keep an track-only check state to keep the dragging behavior smooth
94 * while toggling activations
96 this._trackChecked
= this.checked
;
97 this.$.toggleButton
.classList
.add('dragging');
100 _trackMove: function(track
) {
102 this._x
= Math
.min(this._width
,
103 Math
.max(0, this._trackChecked
? this._width
+ dx
: dx
));
104 this.translate3d(this._x
+ 'px', 0, 0, this.$.toggleButton
);
105 this._userActivate(this._x
> (this._width
/ 2));
108 _trackEnd: function(track
) {
109 this.$.toggleButton
.classList
.remove('dragging');
110 this.transform('', this.$.toggleButton
);