Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Unified Diff: third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js

Issue 899383002: Update paper-toggle-button to 0.5.4 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js
diff --git a/third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js b/third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js
index 7b006be17bf7527679a6b56a95786f1ca368d5fa..72d672ed82b1024c6246c8d496cee0b193d2e5e1 100644
--- a/third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js
+++ b/third_party/polymer/components-chromium/paper-toggle-button/paper-toggle-button-extracted.js
@@ -22,7 +22,7 @@
* @default false
*/
checked: false,
-
+
/**
* If true, the toggle button is disabled. A disabled toggle button cannot
* be tapped or dragged to change the checked state.
@@ -33,23 +33,55 @@
*/
disabled: false,
+ eventDelegates: {
+ down: 'downAction',
+ up: 'upAction',
+ tap: 'tap',
+ trackstart: 'trackStart',
+ trackx: 'trackx',
+ trackend: 'trackEnd'
+ },
+
+ downAction: function(e) {
+ var rect = this.$.ink.getBoundingClientRect();
+ this.$.ink.downAction({
+ x: rect.left + rect.width / 2,
+ y: rect.top + rect.height / 2
+ });
+ },
+
+ upAction: function(e) {
+ this.$.ink.upAction();
+ },
+
+ tap: function() {
+ if (this.disabled) {
+ return;
+ }
+ this.checked = !this.checked;
+ this.fire('change');
+ },
+
trackStart: function(e) {
- this._w = this.$.toggleBar.offsetLeft + this.$.toggleBar.offsetWidth;
+ if (this.disabled) {
+ return;
+ }
+ this._w = this.$.toggleBar.offsetWidth / 2;
e.preventTap();
},
trackx: function(e) {
this._x = Math.min(this._w,
Math.max(0, this.checked ? this._w + e.dx : e.dx));
- this.$.toggleRadio.classList.add('dragging');
- var s = this.$.toggleRadio.style;
+ this.$.toggleButton.classList.add('dragging');
+ var s = this.$.toggleButton.style;
s.webkitTransform = s.transform = 'translate3d(' + this._x + 'px,0,0)';
},
trackEnd: function() {
- var s = this.$.toggleRadio.style;
+ var s = this.$.toggleButton.style;
s.transform = s.webkitTransform = '';
- this.$.toggleRadio.classList.remove('dragging');
+ this.$.toggleButton.classList.remove('dragging');
var old = this.checked;
this.checked = Math.abs(this._x) > this._w / 2;
if (this.checked !== old) {
@@ -60,15 +92,6 @@
checkedChanged: function() {
this.setAttribute('aria-pressed', Boolean(this.checked));
this.fire('core-change');
- },
-
- changeAction: function(e) {
- e.stopPropagation();
- this.fire('change');
- },
-
- stopPropagation: function(e) {
- e.stopPropagation();
}
});

Powered by Google App Engine
This is Rietveld 408576698