From f5d36faf083d380ce6b1d839e9af37cf5f251db8 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Mon, 21 Sep 2015 20:18:20 -0500 Subject: [PATCH] fix(switch): use .switch-activated --- ionic/components/switch/modes/ios.scss | 6 +++--- ionic/components/switch/switch.ts | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ionic/components/switch/modes/ios.scss b/ionic/components/switch/modes/ios.scss index 81a7b61381..e331bcece1 100644 --- a/ionic/components/switch/modes/ios.scss +++ b/ionic/components/switch/modes/ios.scss @@ -73,7 +73,7 @@ ion-switch { } &[aria-checked=true] .switch-icon:before, - .activated .switch-icon:before { + .switch-activated .switch-icon:before { // inner bg track's oval, when checked transform: scale3d(0, 0, 0); } @@ -105,13 +105,13 @@ ion-switch { transform: translate3d($switch-ios-width - $switch-ios-handle-width - ($switch-ios-border-width * 2), 0, 0); } - .activated .switch-icon:after { + .switch-activated .switch-icon:after { // when pressing down on the switch and NOT checked // then make the knob wider width: $switch-ios-handle-width + 6; } - &[aria-checked=true] .activated .switch-icon:after { + &[aria-checked=true] .switch-activated .switch-icon:after { // when pressing down on the switch and IS checked // make the knob wider and move it left a bit left: $switch-ios-border-width - 6; diff --git a/ionic/components/switch/switch.ts b/ionic/components/switch/switch.ts index 5d4e8a2140..2d2ce875d0 100644 --- a/ionic/components/switch/switch.ts +++ b/ionic/components/switch/switch.ts @@ -26,7 +26,7 @@ import {pointerCoord} from '../../util/dom'; 'tappable': 'true', '(touchstart)': 'swtch.pointerDown($event)', '(mousedown)': 'swtch.pointerDown($event)', - '[class.activated]': 'swtch.isActivated' + '[class.switch-activated]': 'swtch.isActivated' } }) class MediaSwitch { @@ -129,6 +129,7 @@ export class Switch extends Ion { self.id = IonInput.nextId(); self.tabIndex = 0; + self.lastTouch = 0; self.onChange = (_) => {}; self.onTouched = (_) => {}; @@ -202,10 +203,10 @@ export class Switch extends Ion { pointerDown(ev) { if (/touch/.test(ev.type)) { - this.isTouch = true; + this.lastTouch = Date.now(); } - if (this.isTouch && /mouse/.test(ev.type)) { + if (this.lastTouch + 999 > Date.now() && /mouse/.test(ev.type)) { return; } @@ -218,7 +219,7 @@ export class Switch extends Ion { } pointerUp(ev) { - if (this.isTouch && /mouse/.test(ev.type)) { + if (this.lastTouch + 999 > Date.now() && /mouse/.test(ev.type)) { return; } @@ -234,7 +235,6 @@ export class Switch extends Ion { this.removeMoveListener(); this.isActivated = false; - this.isTouch = false; } // Used by the view to update the model (Control)