Skip to content

Commit

Permalink
chore: moves 'defaults' out of the constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunkathuria committed Jul 15, 2016
1 parent aa63d5b commit 3dc960e
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 49 deletions.
4 changes: 2 additions & 2 deletions src/recognizerjs/recognizer-constructor.js
Expand Up @@ -54,8 +54,6 @@ import stateStr from './state-str';
*/
export default class Recognizer {
constructor(options) {
Recognizer.prototype.defaults = {};

this.options = assign({}, this.defaults, options || {});

this.id = uniqueId();
Expand Down Expand Up @@ -300,3 +298,5 @@ export default class Recognizer {
*/
reset() { }
}

Recognizer.prototype.defaults = {};
17 changes: 9 additions & 8 deletions src/recognizers/attribute.js
Expand Up @@ -19,14 +19,6 @@ import {
*/
export default class AttrRecognizer extends Recognizer {
constructor() {
AttrRecognizer.prototype.defaults = {
/**
* @private
* @type {Number}
* @default 1
*/
pointers: 1
};
super(...arguments);
}

Expand Down Expand Up @@ -70,3 +62,12 @@ export default class AttrRecognizer extends Recognizer {
return STATE_FAILED;
}
}

AttrRecognizer.prototype.defaults = {
/**
* @private
* @type {Number}
* @default 1
*/
pointers: 1
};
13 changes: 7 additions & 6 deletions src/recognizers/pan.js
Expand Up @@ -22,12 +22,6 @@ import directionStr from '../recognizerjs/direction-str';
*/
export default class PanRecognizer extends AttrRecognizer {
constructor() {
PanRecognizer.prototype.defaults = {
event: 'pan',
threshold: 10,
pointers: 1,
direction: DIRECTION_ALL
};
super(...arguments);
this.pX = null;
this.pY = null;
Expand Down Expand Up @@ -87,3 +81,10 @@ export default class PanRecognizer extends AttrRecognizer {
super.emit(input);
}
}

PanRecognizer.prototype.defaults = {
event: 'pan',
threshold: 10,
pointers: 1,
direction: DIRECTION_ALL
};
11 changes: 6 additions & 5 deletions src/recognizers/pinch.js
Expand Up @@ -11,11 +11,6 @@ import { STATE_BEGAN } from '../recognizerjs/recognizer-consts';
*/
export default class PinchRecognizer extends AttrRecognizer {
constructor() {
PinchRecognizer.prototype.defaults = {
event: 'pinch',
threshold: 0,
pointers: 2
};
super(...arguments);
}

Expand All @@ -36,3 +31,9 @@ export default class PinchRecognizer extends AttrRecognizer {
super.emit(input);
}
}

PinchRecognizer.prototype.defaults = {
event: 'pinch',
threshold: 0,
pointers: 2
};
13 changes: 7 additions & 6 deletions src/recognizers/press.js
Expand Up @@ -21,12 +21,6 @@ import {
*/
export default class PressRecognizer extends Recognizer {
constructor() {
PressRecognizer.prototype.defaults = {
event: 'press',
pointers: 1,
time: 251, // minimal time of the pointer to be pressed
threshold: 9 // a minimal movement is ok, but keep it low
};
super(...arguments);
this._timer = null;
this._input = null;
Expand Down Expand Up @@ -77,3 +71,10 @@ export default class PressRecognizer extends Recognizer {
}
}
}

PressRecognizer.prototype.defaults = {
event: 'press',
pointers: 1,
time: 251, // minimal time of the pointer to be pressed
threshold: 9 // a minimal movement is ok, but keep it low
};
11 changes: 6 additions & 5 deletions src/recognizers/rotate.js
Expand Up @@ -11,11 +11,6 @@ import { STATE_BEGAN } from '../recognizerjs/recognizer-consts';
*/
export default class RotateRecognizer extends AttrRecognizer {
constructor() {
RotateRecognizer.prototype.defaults = {
event: 'rotate',
threshold: 0,
pointers: 2
};
super(...arguments);
}

Expand All @@ -28,3 +23,9 @@ export default class RotateRecognizer extends AttrRecognizer {
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
}
}

RotateRecognizer.prototype.defaults = {
event: 'rotate',
threshold: 0,
pointers: 2
};
17 changes: 9 additions & 8 deletions src/recognizers/swipe.js
Expand Up @@ -12,15 +12,8 @@ import directionStr from '../recognizerjs/direction-str';
* @constructor
* @extends AttrRecognizer
*/
export default class SwipeRecognizer extends AttrRecognizer{
export default class SwipeRecognizer extends AttrRecognizer {
constructor() {
SwipeRecognizer.prototype.defaults = {
event: 'swipe',
threshold: 10,
velocity: 0.3,
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
pointers: 1
};
super(...arguments);
}

Expand Down Expand Up @@ -56,3 +49,11 @@ export default class SwipeRecognizer extends AttrRecognizer{
this.manager.emit(this.options.event, input);
}
}

SwipeRecognizer.prototype.defaults = {
event: 'swipe',
threshold: 10,
velocity: 0.3,
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
pointers: 1
};
19 changes: 10 additions & 9 deletions src/recognizers/tap.js
Expand Up @@ -22,15 +22,6 @@ import getDistance from '../inputjs/get-distance';
*/
export default class TapRecognizer extends Recognizer {
constructor() {
TapRecognizer.prototype.defaults = {
event: 'tap',
pointers: 1,
taps: 1,
interval: 300, // max time between the multi-tap taps
time: 250, // max time of the pointer to be down (like finger on the screen)
threshold: 9, // a minimal movement is ok, but keep it low
posThreshold: 10 // a multi-tap can be a bit off the initial position
};
super(...arguments);

// previous time and center,
Expand Down Expand Up @@ -119,3 +110,13 @@ export default class TapRecognizer extends Recognizer {
}
}
}

TapRecognizer.prototype.defaults = {
event: 'tap',
pointers: 1,
taps: 1,
interval: 300, // max time between the multi-tap taps
time: 250, // max time of the pointer to be down (like finger on the screen)
threshold: 9, // a minimal movement is ok, but keep it low
posThreshold: 10 // a multi-tap can be a bit off the initial position
};

0 comments on commit 3dc960e

Please sign in to comment.