Skip to content

Commit 4557312

Browse files
author
Matt Colman
committed
merge master, resolve conflicts and remove build files
2 parents 417806e + afad206 commit 4557312

19 files changed

+20183
-15910
lines changed

.npmignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
bower.json
2+
dist/
3+
example
4+
gulpfile.js
5+
src/

README.md

+6-14
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ Then open [`localhost:8000`](http://localhost:8000) in a browser.
2929

3030
## Installation
3131

32-
The easiest way to use React-tappable is to install it from NPM and include it in your own React build process (using [Browserify](http://browserify.org), etc).
33-
34-
You can also use the standalone build by including `dist/react-tappable.js` in your page. If you use this, make sure you have already included React, and it is available as a global variable.
32+
The easiest way to use React-tappable is to install it from npm.
3533

3634
```
3735
npm install react-tappable --save
3836
```
3937

38+
Ensure to include it in your own React build process (using [Browserify](http://browserify.org), etc).
39+
40+
You could also use the standalone build by including `dist/react-tappable.js` in your page; but, if you do this, make sure you have already included React, and that it is available globally.
41+
4042

4143
## Usage
4244

@@ -129,14 +131,4 @@ Returning `false` from `onKeyDown`, `onMouseDown`, or `onTouchStart` handlers wi
129131

130132
See [CHANGES.md](https://github.com/JedWatson/react-tappable/blob/master/CHANGES.md)
131133

132-
## License
133-
134-
(The MIT License)
135-
136-
Copyright (c) 2016 Jed Watson
137-
138-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
139-
140-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
141-
142-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
134+
## License [MIT](LICENSE)

dist/react-tappable.js

+40-57
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ module.exports.Mixin = TappableMixin;
1515
(function (global){
1616
'use strict';
1717

18+
var PropTypes = (typeof window !== "undefined" ? window['PropTypes'] : typeof global !== "undefined" ? global['PropTypes'] : null);
1819
var React = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
1920
var ReactDOM = (typeof window !== "undefined" ? window['ReactDOM'] : typeof global !== "undefined" ? global['ReactDOM'] : null);
2021

@@ -33,36 +34,29 @@ function getTouchProps(touch) {
3334

3435
var Mixin = {
3536
propTypes: {
36-
moveThreshold: React.PropTypes.number, // pixels to move before cancelling tap
37-
moveXThreshold: React.PropTypes.number, // pixels on the x axis to move before cancelling tap (overrides moveThreshold)
38-
moveYThreshold: React.PropTypes.number, // pixels on the y axis to move before cancelling tap (overrides moveThreshold)
39-
activeDelay: React.PropTypes.number, // ms to wait before adding the `-active` class
40-
allowReactivation: React.PropTypes.bool, // after moving outside of the moveThreshold will you allow
41-
// reactivation by moving back within the moveThreshold?
42-
pressDelay: React.PropTypes.number, // ms to wait before detecting a press
43-
pressMoveThreshold: React.PropTypes.number, // pixels to move before cancelling press
44-
preventDefault: React.PropTypes.bool, // whether to preventDefault on all events
45-
stopPropagation: React.PropTypes.bool, // whether to stopPropagation on all events
46-
47-
onTap: React.PropTypes.func, // fires when a tap is detected
48-
onDeactivate: React.PropTypes.func, // fires when you move outside the moveThreshold
49-
onReactivate: React.PropTypes.func, // fires when you move back within the moveThreshold
50-
onPress: React.PropTypes.func, // fires when a press is detected
51-
onTouchStart: React.PropTypes.func, // pass-through touch event
52-
onTouchMove: React.PropTypes.func, // pass-through touch event
53-
onTouchEnd: React.PropTypes.func, // pass-through touch event
54-
onMouseDown: React.PropTypes.func, // pass-through mouse event
55-
onMouseUp: React.PropTypes.func, // pass-through mouse event
56-
onMouseMove: React.PropTypes.func, // pass-through mouse event
57-
onMouseOut: React.PropTypes.func, // pass-through mouse event
58-
onKeyDown: React.PropTypes.func, // pass-through key event
59-
onKeyUp: React.PropTypes.func },
37+
moveThreshold: PropTypes.number, // pixels to move before cancelling tap
38+
activeDelay: PropTypes.number, // ms to wait before adding the `-active` class
39+
pressDelay: PropTypes.number, // ms to wait before detecting a press
40+
pressMoveThreshold: PropTypes.number, // pixels to move before cancelling press
41+
preventDefault: PropTypes.bool, // whether to preventDefault on all events
42+
stopPropagation: PropTypes.bool, // whether to stopPropagation on all events
43+
44+
onTap: PropTypes.func, // fires when a tap is detected
45+
onPress: PropTypes.func, // fires when a press is detected
46+
onTouchStart: PropTypes.func, // pass-through touch event
47+
onTouchMove: PropTypes.func, // pass-through touch event
48+
onTouchEnd: PropTypes.func, // pass-through touch event
49+
onMouseDown: PropTypes.func, // pass-through mouse event
50+
onMouseUp: PropTypes.func, // pass-through mouse event
51+
onMouseMove: PropTypes.func, // pass-through mouse event
52+
onMouseOut: PropTypes.func, // pass-through mouse event
53+
onKeyDown: PropTypes.func, // pass-through key event
54+
onKeyUp: PropTypes.func },
6055

6156
// pass-through key event
6257
getDefaultProps: function getDefaultProps() {
6358
return {
6459
activeDelay: 0,
65-
allowReactivation: true,
6660
moveThreshold: 100,
6761
pressDelay: 1000,
6862
pressMoveThreshold: 5
@@ -83,14 +77,6 @@ var Mixin = {
8377
this.clearActiveTimeout();
8478
},
8579

86-
componentWillUpdate: function componentWillUpdate(nextProps, nextState) {
87-
if (this.state.isActive && !nextState.isActive) {
88-
this.props.onDeactivate && this.props.onDeactivate();
89-
} else if (!this.state.isActive && nextState.isActive) {
90-
this.props.onReactivate && this.props.onReactivate();
91-
}
92-
},
93-
9480
processEvent: function processEvent(event) {
9581
if (this.props.preventDefault) event.preventDefault();
9682
if (this.props.stopPropagation) event.stopPropagation();
@@ -105,10 +91,10 @@ var Mixin = {
10591
this.initScrollDetection();
10692
this.initPressDetection(event, this.endTouch);
10793
this.initTouchmoveDetection();
108-
if (this.props.activeDelay === 0) {
109-
this.makeActive();
110-
} else {
94+
if (this.props.activeDelay > 0) {
11195
this._activeTimeout = setTimeout(this.makeActive, this.props.activeDelay);
96+
} else {
97+
this.makeActive();
11298
}
11399
} else if (this.onPinchStart && (this.props.onPinchStart || this.props.onPinchMove || this.props.onPinchEnd) && event.touches.length === 2) {
114100
this.onPinchStart(event);
@@ -181,6 +167,10 @@ var Mixin = {
181167

182168
initPressDetection: function initPressDetection(event, callback) {
183169
if (!this.props.onPress) return;
170+
171+
// SyntheticEvent objects are pooled, so persist the event so it can be referenced asynchronously
172+
event.persist();
173+
184174
this._pressTimeout = setTimeout((function () {
185175
this.props.onPress(event);
186176
callback();
@@ -213,15 +203,11 @@ var Mixin = {
213203
if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) {
214204
this.cancelPressDetection();
215205
}
216-
if (movement.x > (this.props.moveXThreshold || this.props.moveThreshold) || movement.y > (this.props.moveYThreshold || this.props.moveThreshold)) {
206+
if (movement.x > this.props.moveThreshold || movement.y > this.props.moveThreshold) {
217207
if (this.state.isActive) {
218-
if (this.props.allowReactivation) {
219-
this.setState({
220-
isActive: false
221-
});
222-
} else {
223-
return this.endTouch(event);
224-
}
208+
this.setState({
209+
isActive: false
210+
});
225211
} else if (this._activeTimeout) {
226212
this.clearActiveTimeout();
227213
}
@@ -245,7 +231,7 @@ var Mixin = {
245231
this.processEvent(event);
246232
var afterEndTouch;
247233
var movement = this.calculateMovement(this._lastTouch);
248-
if (movement.x <= (this.props.moveXThreshold || this.props.moveThreshold) && movement.y <= (this.props.moveYThreshold || this.props.moveThreshold) && this.props.onTap) {
234+
if (movement.x <= this.props.moveThreshold && movement.y <= this.props.moveThreshold && this.props.onTap) {
249235
event.preventDefault();
250236
afterEndTouch = function () {
251237
var finalParentScrollPos = _this._scrollParents.map(function (node) {
@@ -389,6 +375,8 @@ module.exports = Mixin;
389375

390376
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
391377

378+
var createReactClass = (typeof window !== "undefined" ? window['createReactClass'] : typeof global !== "undefined" ? global['createReactClass'] : null);
379+
var PropTypes = (typeof window !== "undefined" ? window['PropTypes'] : typeof global !== "undefined" ? global['PropTypes'] : null);
392380
var React = (typeof window !== "undefined" ? window['React'] : typeof global !== "undefined" ? global['React'] : null);
393381
var touchStyles = require('./touchStyles');
394382

@@ -397,18 +385,18 @@ var touchStyles = require('./touchStyles');
397385
* ==================
398386
*/
399387
module.exports = function (mixins) {
400-
return React.createClass({
388+
return createReactClass({
401389
displayName: 'Tappable',
402390

403391
mixins: mixins,
404392

405393
propTypes: {
406-
component: React.PropTypes.any, // component to create
407-
className: React.PropTypes.string, // optional className
408-
classBase: React.PropTypes.string, // base for generated classNames
409-
classes: React.PropTypes.object, // object containing the active and inactive class names
410-
style: React.PropTypes.object, // additional style properties for the component
411-
disabled: React.PropTypes.bool // only applies to buttons
394+
component: PropTypes.any, // component to create
395+
className: PropTypes.string, // optional className
396+
classBase: PropTypes.string, // base for generated classNames
397+
classes: PropTypes.object, // object containing the active and inactive class names
398+
style: PropTypes.object, // additional style properties for the component
399+
disabled: PropTypes.bool // only applies to buttons
412400
},
413401

414402
getDefaultProps: function getDefaultProps() {
@@ -441,7 +429,6 @@ module.exports = function (mixins) {
441429
}, this.handlers());
442430

443431
delete newComponentProps.activeDelay;
444-
delete newComponentProps.allowReactivation;
445432
delete newComponentProps.classBase;
446433
delete newComponentProps.classes;
447434
delete newComponentProps.handlers;
@@ -450,11 +437,7 @@ module.exports = function (mixins) {
450437
delete newComponentProps.onPinchStart;
451438
delete newComponentProps.onPinchMove;
452439
delete newComponentProps.onPinchEnd;
453-
delete newComponentProps.onDeactivate;
454-
delete newComponentProps.onReactivate;
455440
delete newComponentProps.moveThreshold;
456-
delete newComponentProps.moveXThreshold;
457-
delete newComponentProps.moveYThreshold;
458441
delete newComponentProps.pressDelay;
459442
delete newComponentProps.pressMoveThreshold;
460443
delete newComponentProps.preventDefault;

0 commit comments

Comments
 (0)