Skip to content

Commit

Permalink
Merge pull request #50 from vaadin/fix/add-gesture-events
Browse files Browse the repository at this point in the history
Polymer.GestureEventListeners
  • Loading branch information
tomivirkki authored Sep 20, 2017
2 parents f8de34e + bace622 commit 0a598fc
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions vaadin-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
-->

<link rel="import" href="../polymer/polymer-element.html">
<link rel="import" href="../polymer/lib/mixins/gesture-event-listeners.html">
<link rel="import" href="../vaadin-themable-mixin/vaadin-themable-mixin.html">
<link rel="import" href="../vaadin-control-state-mixin/vaadin-control-state-mixin.html">

Expand Down Expand Up @@ -70,9 +71,10 @@
* @memberof Vaadin
* @mixes Vaadin.ControlStateMixin
* @mixes Vaadin.ThemableMixin
* @mixes Polymer.GestureEventListeners
* @demo demo/index.html
*/
class ButtonElement extends Vaadin.ControlStateMixin(Vaadin.ThemableMixin(Polymer.Element)) {
class ButtonElement extends Vaadin.ControlStateMixin(Vaadin.ThemableMixin(Polymer.GestureEventListeners(Polymer.Element))) {
static get is() {
return 'vaadin-button';
}
Expand All @@ -91,8 +93,8 @@
}

_addActiveListeners() {
this._addEventListenerToNode(this, 'down', () => !this.disabled && this.setAttribute('active', ''));
this._addEventListenerToNode(this, 'up', () => this.removeAttribute('active'));
Polymer.Gestures.addListener(this, 'down', () => !this.disabled && this.setAttribute('active', ''));
Polymer.Gestures.addListener(this, 'up', () => this.removeAttribute('active'));
this.addEventListener('keydown', e => !this.disabled && [13, 32].indexOf(e.keyCode) >= 0 && this.setAttribute('active', ''));
this.addEventListener('keyup', () => this.removeAttribute('active'));
}
Expand Down

0 comments on commit 0a598fc

Please sign in to comment.