Skip to content

Commit

Permalink
fix missing updated lib/ files
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Apr 3, 2018
1 parent 3f24e83 commit bfe1019
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 24 deletions.
6 changes: 2 additions & 4 deletions lib/PinchableMixin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

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; };

var PropTypes = require('prop-types');
var React = require('react');

Expand Down Expand Up @@ -30,7 +28,7 @@ var Mixin = {
}
var touches = event.touches;
this._initialPinch = getPinchProps(touches);
this._initialPinch = _extends(this._initialPinch, {
this._initialPinch = Object.assign(this._initialPinch, {
displacement: { x: 0, y: 0 },
displacementVelocity: { x: 0, y: 0 },
rotation: 0,
Expand Down Expand Up @@ -82,7 +80,7 @@ var Mixin = {

onPinchEnd: function onPinchEnd(event) {
// TODO use helper to order touches by identifier and use actual values on touchEnd.
var currentPinch = _extends({}, this._lastPinch);
var currentPinch = Object.assign({}, this._lastPinch);
currentPinch.time = Date.now();

if (currentPinch.time - this._lastPinch.time > 16) {
Expand Down
4 changes: 1 addition & 3 deletions lib/TapAndPinchable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

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; };

var TappableMixin = require('./TappableMixin');
var PinchableMixin = require('./PinchableMixin');
var getComponent = require('./getComponent');
Expand All @@ -11,7 +9,7 @@ var Component = getComponent([TappableMixin, PinchableMixin]);

module.exports = Component;
module.exports.touchStyles = touchStyles;
module.exports.Mixin = _extends({}, TappableMixin, {
module.exports.Mixin = Object.assign({}, TappableMixin, {
onPinchStart: PinchableMixin.onPinchStart,
onPinchMove: PinchableMixin.onPinchMove,
onPinchEnd: PinchableMixin.onPinchEnd
Expand Down
41 changes: 29 additions & 12 deletions lib/TappableMixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ function getTouchProps(touch) {
var Mixin = {
propTypes: {
moveThreshold: PropTypes.number, // pixels to move before cancelling tap
moveXThreshold: PropTypes.number, // pixels on the x axis to move before cancelling tap (overrides moveThreshold)
moveYThreshold: PropTypes.number, // pixels on the y axis to move before cancelling tap (overrides moveThreshold)
allowReactivation: PropTypes.bool, // after moving outside of the moveThreshold will you allow
// reactivation by moving back within the moveThreshold?
activeDelay: PropTypes.number, // ms to wait before adding the `-active` class
pressDelay: PropTypes.number, // ms to wait before detecting a press
pressMoveThreshold: PropTypes.number, // pixels to move before cancelling press
Expand All @@ -36,12 +40,13 @@ var Mixin = {
onMouseMove: PropTypes.func, // pass-through mouse event
onMouseOut: PropTypes.func, // pass-through mouse event
onKeyDown: PropTypes.func, // pass-through key event
onKeyUp: PropTypes.func },
onKeyUp: PropTypes.func // pass-through key event
},

// pass-through key event
getDefaultProps: function getDefaultProps() {
return {
activeDelay: 0,
allowReactivation: true,
moveThreshold: 100,
pressDelay: 1000,
pressMoveThreshold: 5
Expand All @@ -67,6 +72,14 @@ var Mixin = {
this.clearActiveTimeout();
},

componentWillUpdate: function componentWillUpdate(nextProps, nextState) {
if (this.state.isActive && !nextState.isActive) {
this.props.onDeactivate && this.props.onDeactivate();
} else if (!this.state.isActive && nextState.isActive) {
this.props.onReactivate && this.props.onReactivate();
}
},

processEvent: function processEvent(event) {
if (this.props.preventDefault) event.preventDefault();
if (this.props.stopPropagation) event.stopPropagation();
Expand Down Expand Up @@ -161,10 +174,10 @@ var Mixin = {
// SyntheticEvent objects are pooled, so persist the event so it can be referenced asynchronously
event.persist();

this._pressTimeout = setTimeout((function () {
this._pressTimeout = setTimeout(function () {
this.props.onPress(event);
callback();
}).bind(this), this.props.pressDelay);
}.bind(this), this.props.pressDelay);
},

cancelPressDetection: function cancelPressDetection() {
Expand All @@ -179,11 +192,11 @@ var Mixin = {
return this.endTouch(event);
} else {
if (this._touchmoveTriggeredTimes++ === 0) {
this._touchmoveDetectionTimeout = setTimeout((function () {
this._touchmoveDetectionTimeout = setTimeout(function () {
if (this._touchmoveTriggeredTimes === 1) {
this.endTouch(event);
}
}).bind(this), 64);
}.bind(this), 64);
}
}

Expand All @@ -193,11 +206,15 @@ var Mixin = {
if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) {
this.cancelPressDetection();
}
if (movement.x > this.props.moveThreshold || movement.y > this.props.moveThreshold) {
if (movement.x > (this.props.moveXThreshold || this.props.moveThreshold) || movement.y > (this.props.moveYThreshold || this.props.moveThreshold)) {
if (this.state.isActive) {
this.setState({
isActive: false
});
if (this.props.allowReactivation) {
this.setState({
isActive: false
});
} else {
return this.endTouch(event);
}
} else if (this._activeTimeout) {
this.clearActiveTimeout();
}
Expand All @@ -221,9 +238,9 @@ var Mixin = {
this.processEvent(event);
var afterEndTouch;
var movement = this.calculateMovement(this._lastTouch);
if (movement.x <= this.props.moveThreshold && movement.y <= this.props.moveThreshold && this.props.onTap) {
if (movement.x <= (this.props.moveXThreshold || this.props.moveThreshold) && movement.y <= (this.props.moveYThreshold || this.props.moveThreshold) && this.props.onTap) {
event.preventDefault();
afterEndTouch = function () {
afterEndTouch = function afterEndTouch() {
var finalParentScrollPos = _this._scrollParents.map(function (node) {
return node.scrollTop + node.scrollLeft;
});
Expand Down
6 changes: 2 additions & 4 deletions lib/getComponent.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

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; };

var createReactClass = require('create-react-class');
var PropTypes = require('prop-types');
var React = require('react');
Expand Down Expand Up @@ -46,9 +44,9 @@ module.exports = function (mixins) {
}

var style = {};
_extends(style, touchStyles, props.style);
Object.assign(style, touchStyles, props.style);

var newComponentProps = _extends({}, props, {
var newComponentProps = Object.assign({}, props, {
style: style,
className: className,
disabled: props.disabled,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-dom": "^0.14 || ^15.0.0-rc || ^15.0.0 || ^16.0.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-eslint": "^4.1.3",
"babel-preset-es2015": "^6.24.1",
Expand Down Expand Up @@ -43,7 +44,8 @@
"react-dom": "global:ReactDOM"
},
"scripts": {
"build": "browserify src/TapAndPinchable.js --standalone ReactTappable --transform [ babelify ] > dist/react-tappable.js",
"build": "babel src --out-dir lib",
"dist": "browserify src/TapAndPinchable.js --standalone ReactTappable --transform [ babelify ] > dist/react-tappable.js",
"start": "gulp dev",
"examples": "gulp dev:server",
"lint": "eslint ./; true",
Expand Down

0 comments on commit bfe1019

Please sign in to comment.