Skip to content

Commit

Permalink
Make sure UglifyJS works
Browse files Browse the repository at this point in the history
Fixes #110
  • Loading branch information
s0meone committed Sep 29, 2017
1 parent e0036d0 commit 5f741e8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
3 changes: 3 additions & 0 deletions demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
"version": "0.0.1",
"devDependencies": {
"browserify": "11.2.0",
"envify": "4.1.0",
"react": "^16.0.0-0",
"react-dom": "^16.0.0-0",
"react-tap-event-plugin": "../",
"uglifyify": "4.0.4",
"watchify": "3.9.0"
},
"scripts": {
"build": "browserify src/application.js -o application.js",
"dist": "NODE_ENV=production browserify -t envify -g uglifyify src/application.js -o application.js",
"watch": "watchify src/application.js -o application.js -v"
},
"dependencies": {}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-tap-event-plugin",
"version": "3.0.0",
"version": "3.0.1",
"description": "Facebook's TapEventPlugin, temporarily available on npm until its made public in their repo",
"main": "src/injectTapEventPlugin.js",
"files": [
Expand Down
32 changes: 16 additions & 16 deletions src/SyntheticEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var shouldBeReleasedProperties = [
'isDefaultPrevented',
'isPropagationStopped',
'_dispatchListeners',
'_dispatchInstances',
'_dispatchInstances'
];

/**
Expand All @@ -50,7 +50,7 @@ var EventInterface = {
return event.timeStamp || Date.now();
},
defaultPrevented: null,
isTrusted: null,
isTrusted: null
};

/**
Expand All @@ -75,7 +75,7 @@ function SyntheticEvent(
dispatchConfig,
targetInst,
nativeEvent,
nativeEventTarget,
nativeEventTarget
) {
if (__DEV__) {
// these have a getter/setter for warnings
Expand Down Expand Up @@ -182,7 +182,7 @@ Object.assign(SyntheticEvent.prototype, {
Object.defineProperty(
this,
propName,
getPooledWarningPropertyDefinition(propName, Interface[propName]),
getPooledWarningPropertyDefinition(propName, Interface[propName])
);
} else {
this[propName] = null;
Expand All @@ -195,20 +195,20 @@ Object.assign(SyntheticEvent.prototype, {
Object.defineProperty(
this,
'nativeEvent',
getPooledWarningPropertyDefinition('nativeEvent', null),
getPooledWarningPropertyDefinition('nativeEvent', null)
);
Object.defineProperty(
this,
'preventDefault',
getPooledWarningPropertyDefinition('preventDefault', emptyFunction),
getPooledWarningPropertyDefinition('preventDefault', emptyFunction)
);
Object.defineProperty(
this,
'stopPropagation',
getPooledWarningPropertyDefinition('stopPropagation', emptyFunction),
getPooledWarningPropertyDefinition('stopPropagation', emptyFunction)
);
}
},
}
});

SyntheticEvent.Interface = EventInterface;
Expand Down Expand Up @@ -259,15 +259,15 @@ if (__DEV__) {
"This synthetic event is reused for performance reasons. If you're " +
"seeing this, you're adding a new property in the synthetic event object. " +
'The property is never released. See ' +
'https://fb.me/react-event-pooling for more information.',
'https://fb.me/react-event-pooling for more information.'
);
didWarnForAddedNewProperty = true;
}
target[prop] = value;
return true;
},
}
});
},
}
});
/*eslint-enable no-func-assign */
}
Expand All @@ -289,7 +289,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
return {
configurable: true,
set: set,
get: get,
get: get
};

function set(val) {
Expand Down Expand Up @@ -317,7 +317,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) {
'See https://fb.me/react-event-pooling for more information.',
action,
propName,
result,
result
);
}
}
Expand All @@ -331,23 +331,23 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) {
dispatchConfig,
targetInst,
nativeEvent,
nativeInst,
nativeInst
);
return instance;
}
return new EventConstructor(
dispatchConfig,
targetInst,
nativeEvent,
nativeInst,
nativeInst
);
}

function releasePooledEvent(event) {
var EventConstructor = this;
invariant(
event instanceof EventConstructor,
'Trying to release an event instance into a pool of a different type.',
'Trying to release an event instance into a pool of a different type.'
);
event.destructor();
if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) {
Expand Down
20 changes: 10 additions & 10 deletions src/TapEventPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var startCoords = {x: 0, y: 0};

var Axis = {
x: {page: 'pageX', client: 'clientX', envScroll: 'currentPageScrollLeft'},
y: {page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop'},
y: {page: 'pageY', client: 'clientY', envScroll: 'currentPageScrollTop'}
};

function getAxisCoordOfEvent(
Expand All @@ -54,29 +54,29 @@ function getDistance(coords, nativeEvent) {
var pageY = getAxisCoordOfEvent(Axis.y, nativeEvent);
return Math.pow(
Math.pow(pageX - coords.x, 2) + Math.pow(pageY - coords.y, 2),
0.5,
0.5
);
}

var touchEvents = [
'topTouchStart',
'topTouchCancel',
'topTouchEnd',
'topTouchMove',
'topTouchMove'
];

var dependencies = ['topMouseDown', 'topMouseMove', 'topMouseUp'].concat(
touchEvents,
touchEvents
);

var eventTypes = {
touchTap: {
phasedRegistrationNames: {
bubbled: 'onTouchTap',
captured: 'onTouchTapCapture',
captured: 'onTouchTapCapture'
},
dependencies: dependencies,
},
dependencies: dependencies
}
};

var usedTouchTime = 0;
Expand All @@ -92,7 +92,7 @@ function createTapEventPlugin(shouldRejectClick) {
topLevelType,
targetInst,
nativeEvent,
nativeEventTarget,
nativeEventTarget
) {
if (!isStartish(topLevelType) && !isEndish(topLevelType)) {
return null;
Expand All @@ -114,7 +114,7 @@ function createTapEventPlugin(shouldRejectClick) {
eventTypes.touchTap,
targetInst,
nativeEvent,
nativeEventTarget,
nativeEventTarget
);
}
if (isStartish(topLevelType)) {
Expand All @@ -126,7 +126,7 @@ function createTapEventPlugin(shouldRejectClick) {
}
EventPropagators.accumulateTwoPhaseDispatches(event);
return event;
},
}
};
}

Expand Down

0 comments on commit 5f741e8

Please sign in to comment.