Skip to content

Commit

Permalink
style(arrow functions): adds the nice ES6 arrow-function syntax for c…
Browse files Browse the repository at this point in the history
…allbacks
  • Loading branch information
arjunkathuria authored and arschmitz committed Sep 30, 2016
1 parent 6b415f6 commit c337e87
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .jscsrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"tests/**/assets",
"node_modules/**"
],
"disallowConstOutsideModuleScope": false
"disallowConstOutsideModuleScope": false,
"requireArrowFunctions": true,
}
2 changes: 1 addition & 1 deletion src/input/touch.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function getTouches(ev, type) {
let { target } = this;

// get target touches from touches
targetTouches = allTouches.filter(function(touch) {
targetTouches = allTouches.filter((touch) => {
return hasParent(touch.target, target);
});

Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ freeGlobal.Hammer = Hammer;

/* jshint ignore:start */
if (typeof define === 'function' && define.amd) {
define(function() {
define(() => {
return Hammer;
});
} else if (typeof module !== 'undefined' && module.exports) {
Expand Down
8 changes: 4 additions & 4 deletions src/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Manager(element, options) {

toggleCssProps(this, true);

each(this.options.recognizers, function(item) {
each(this.options.recognizers, (item) => {
let recognizer = this.add(new (item[0])(item[1]));
item[2] && recognizer.recognizeWith(item[2]);
item[3] && recognizer.requireFailure(item[3]);
Expand Down Expand Up @@ -226,7 +226,7 @@ Manager.prototype = {
}

let { handlers } = this;
each(splitStr(events), function(event) {
each(splitStr(events), (event) => {
handlers[event] = handlers[event] || [];
handlers[event].push(handler);
});
Expand All @@ -245,7 +245,7 @@ Manager.prototype = {
}

let { handlers } = this;
each(splitStr(events), function(event) {
each(splitStr(events), (event) => {
if (!handler) {
delete handlers[event];
} else {
Expand Down Expand Up @@ -311,7 +311,7 @@ function toggleCssProps(manager, add) {
return;
}
let prop;
each(manager.options.cssProps, function(value, name) {
each(manager.options.cssProps, (value, name) => {
prop = prefixed(element.style, name);
if (add) {
manager.oldCssProps[prop] = element.style[prop];
Expand Down
2 changes: 1 addition & 1 deletion src/recognizers/press.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ inherit(PressRecognizer, Recognizer, {
this.reset();
} else if (input.eventType & INPUT_START) {
this.reset();
this._timer = setTimeoutContext(function() {
this._timer = setTimeoutContext(() => {
this.state = STATE_RECOGNIZED;
this.tryEmit();
}, options.time, this);
Expand Down
4 changes: 2 additions & 2 deletions src/recognizers/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ inherit(TapRecognizer, Recognizer, {
if (!this.hasRequireFailures()) {
return STATE_RECOGNIZED;
} else {
this._timer = setTimeoutContext(function() {
this._timer = setTimeoutContext(() => {
this.state = STATE_RECOGNIZED;
this.tryEmit();
}, options.interval, this);
Expand All @@ -109,7 +109,7 @@ inherit(TapRecognizer, Recognizer, {
},

failTimeout() {
this._timer = setTimeoutContext(function() {
this._timer = setTimeoutContext(() => {
this.state = STATE_FAILED;
}, this.options.interval, this);
return STATE_FAILED;
Expand Down
4 changes: 2 additions & 2 deletions src/touchactionjs/get-touchaction-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ export default function getTouchActionProps() {
}
let touchMap = {};
let cssSupports = window.CSS && window.CSS.supports;
['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach(function(val) {
['auto', 'manipulation', 'pan-y', 'pan-x', 'pan-x pan-y', 'none'].forEach((val) => {

// If css.supports is not supported but there is native touch-action assume it supports
// all values. This is the case for IE 10 and 11.
touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
return touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
});
return touchMap;
}
2 changes: 1 addition & 1 deletion src/touchactionjs/touchaction-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ TouchAction.prototype = {
*/
compute() {
let actions = [];
each(this.manager.recognizers, function(recognizer) {
each(this.manager.recognizers, (recognizer) => {
if (boolOrFn(recognizer.options.enable, [recognizer])) {
actions = actions.concat(recognizer.getTouchAction());
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/add-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import splitStr from './split-str';
* @param {Function} handler
*/
export default function addEventListeners(target, types, handler) {
each(splitStr(types), function(type) {
each(splitStr(types), (type) => {
target.addEventListener(type, handler, false);
});
}
2 changes: 1 addition & 1 deletion src/utils/extend.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import deprecate from './deprecate';
* @param {Boolean} [merge=false]
* @returns {Object} dest
*/
const extend = deprecate(function extend(dest, src, merge) {
const extend = deprecate((dest, src, merge) => {
let keys = Object.keys(src);
let i = 0;
while (i < keys.length) {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import extend from './extend';
* @param {Object} src
* @returns {Object} dest
*/
const merge = deprecate(function merge(dest, src) {
const merge = deprecate((dest, src) => {
return extend(dest, src, true);
}, 'merge', 'Use `assign`.');

Expand Down
2 changes: 1 addition & 1 deletion src/utils/remove-event-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import splitStr from './split-str';
* @param {Function} handler
*/
export default function removeEventListeners(target, types, handler) {
each(splitStr(types), function(type) {
each(splitStr(types), (type) => {
target.removeEventListener(type, handler, false);
});
}
2 changes: 1 addition & 1 deletion src/utils/unique-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function uniqueArray(src, key, sort) {
if (!key) {
results = results.sort();
} else {
results = results.sort(function sortUniqueArray(a, b) {
results = results.sort((a, b) => {
return a[key] > b[key];
});
}
Expand Down

0 comments on commit c337e87

Please sign in to comment.