Skip to content

Commit

Permalink
fix(ons-switch): Closes #2341.
Browse files Browse the repository at this point in the history
  • Loading branch information
frandiox committed Feb 16, 2018
1 parent a95d7e2 commit 0288980
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -12,10 +12,11 @@ dev
### Bug Fixes

* ons-tabbar: Fixed [#2316](https://github.com/OnsenUI/OnsenUI/issues/2316).
* ons-tabbar: Fixed [#2343](https://github.com/OnsenUI/OnsenUI/issues/2343).
* ons-splitter-side: Fixed [#2271](https://github.com/OnsenUI/OnsenUI/issues/2271).
* ons-navigator: Fixed [#2333](https://github.com/OnsenUI/OnsenUI/issues/2333).
* ons-select (fastclick): Fixed [#2352](https://github.com/OnsenUI/OnsenUI/issues/2352).
* ons-tabbar: Fixed [#2343](https://github.com/OnsenUI/OnsenUI/issues/2343).
* ons-switch: Fixed [#2341](https://github.com/OnsenUI/OnsenUI/issues/2341).

2.9.1
----
Expand Down
6 changes: 4 additions & 2 deletions core/src/elements/ons-switch.js
Expand Up @@ -68,6 +68,7 @@ export default class SwitchElement extends BaseCheckboxElement {

this._onChange = this._onChange.bind(this);
this._onRelease = this._onRelease.bind(this);
this._lastTimeStamp = 0;
}

get _scheme() {
Expand Down Expand Up @@ -118,7 +119,7 @@ export default class SwitchElement extends BaseCheckboxElement {

_onClick(ev) {
if (ev.target.classList.contains(`${this.defaultElementClass}__touch`)
|| ev.timeStamp === this._lastTimeStamp // Prevent second click triggered by <label>
|| (ev.timeStamp - this._lastTimeStamp < 50) // Prevent second click triggered by <label>
) {
ev.preventDefault();
}
Expand Down Expand Up @@ -170,10 +171,11 @@ export default class SwitchElement extends BaseCheckboxElement {
ModifierUtil.removeModifier(this, 'active');
}

click() {
click(ev = {}) {
if (!this.disabled) {
this.checked = !this.checked;
this._emitChangeEvent();
this._lastTimeStamp = ev.timeStamp || 0;
}
}

Expand Down

0 comments on commit 0288980

Please sign in to comment.