react-point
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -11,4 +11,2 @@ 'use strict'; | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -74,22 +72,14 @@ | ||
PointTarget.prototype.render = function render() { | ||
var _props = this.props; | ||
var component = _props.component; | ||
var children = this.props.children; | ||
var props = _objectWithoutProperties(_props, ['component']); | ||
// Let React setup event handlers for us. | ||
// TODO: Warn if they try to pass these props in? | ||
var element = children ? _react2.default.Children.only(children) : _react2.default.createElement('button', null); | ||
props.onClick = this.handleClick; | ||
props.onTouchStart = this.handleTouchStart; | ||
props.onTouchMove = this.handleTouchMove; | ||
props.onTouchCancel = this.handleTouchCancel; | ||
props.onTouchEnd = this.handleTouchEnd; | ||
// Avoid unknown props warning. | ||
delete props.onPoint; | ||
delete props.tolerance; | ||
return _react2.default.createElement(component, props); | ||
return _react2.default.cloneElement(element, { | ||
onClick: this.handleClick, | ||
onTouchStart: this.handleTouchStart, | ||
onTouchMove: this.handleTouchMove, | ||
onTouchCancel: this.handleTouchCancel, | ||
onTouchEnd: this.handleTouchEnd | ||
}); | ||
}; | ||
@@ -101,3 +91,3 @@ | ||
PointTarget.propTypes = { | ||
component: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.string]).isRequired, | ||
children: _react.PropTypes.node, | ||
tolerance: _react.PropTypes.number, | ||
@@ -107,5 +97,4 @@ onPoint: _react.PropTypes.func | ||
PointTarget.defaultProps = { | ||
component: 'div', | ||
tolerance: 10 | ||
}; | ||
exports.default = PointTarget; |
{ | ||
"name": "react-point", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "A minimal click/tap component for React", | ||
"repository": "mjackson/react-point", | ||
"repository": "ReactTraining/react-point", | ||
"author": "Michael Jackson", | ||
@@ -20,3 +20,4 @@ "license": "MIT", | ||
"release": "node ./scripts/release.js", | ||
"test": "karma start" | ||
"lint": "eslint modules", | ||
"test": "npm run lint && karma start" | ||
}, | ||
@@ -28,2 +29,3 @@ "peerDependencies": { | ||
"babel-cli": "^6.11.4", | ||
"babel-eslint": "^6.1.2", | ||
"babel-loader": "^6.2.4", | ||
@@ -34,2 +36,5 @@ "babel-preset-es2015": "^6.9.0", | ||
"babel-preset-stage-1": "^6.5.0", | ||
"eslint": "^3.2.2", | ||
"eslint-plugin-import": "^1.12.0", | ||
"eslint-plugin-react": "^6.0.0", | ||
"expect": "^1.20.2", | ||
@@ -36,0 +41,0 @@ "gzip-size": "^3.0.0", |
@@ -84,4 +84,2 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -147,22 +145,14 @@ | ||
PointTarget.prototype.render = function render() { | ||
var _props = this.props; | ||
var component = _props.component; | ||
var children = this.props.children; | ||
var props = _objectWithoutProperties(_props, ['component']); | ||
// Let React setup event handlers for us. | ||
// TODO: Warn if they try to pass these props in? | ||
var element = children ? _react2.default.Children.only(children) : _react2.default.createElement('button', null); | ||
props.onClick = this.handleClick; | ||
props.onTouchStart = this.handleTouchStart; | ||
props.onTouchMove = this.handleTouchMove; | ||
props.onTouchCancel = this.handleTouchCancel; | ||
props.onTouchEnd = this.handleTouchEnd; | ||
// Avoid unknown props warning. | ||
delete props.onPoint; | ||
delete props.tolerance; | ||
return _react2.default.createElement(component, props); | ||
return _react2.default.cloneElement(element, { | ||
onClick: this.handleClick, | ||
onTouchStart: this.handleTouchStart, | ||
onTouchMove: this.handleTouchMove, | ||
onTouchCancel: this.handleTouchCancel, | ||
onTouchEnd: this.handleTouchEnd | ||
}); | ||
}; | ||
@@ -174,3 +164,3 @@ | ||
PointTarget.propTypes = { | ||
component: _react.PropTypes.oneOfType([_react.PropTypes.func, _react.PropTypes.string]).isRequired, | ||
children: _react.PropTypes.node, | ||
tolerance: _react.PropTypes.number, | ||
@@ -180,3 +170,2 @@ onPoint: _react.PropTypes.func | ||
PointTarget.defaultProps = { | ||
component: 'div', | ||
tolerance: 10 | ||
@@ -183,0 +172,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactPoint=e(require("react")):t.ReactPoint=e(t.React)}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.PointTarget=void 0;var r=o(1),c=n(r);e.PointTarget=c["default"]},function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){var o={};for(var n in t)e.indexOf(n)>=0||Object.prototype.hasOwnProperty.call(t,n)&&(o[n]=t[n]);return o}function c(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function i(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var a=o(2),p=n(a),s=function(t){return t.touches[0].clientX},l=function(t){return t.touches[0].clientY},f=function(t){function e(){var o,n,r;c(this,e);for(var i=arguments.length,a=Array(i),p=0;p<i;p++)a[p]=arguments[p];return o=n=u(this,t.call.apply(t,[this].concat(a))),n.handleClick=function(){!n.usingTouch&&n.props.onPoint&&n.props.onPoint()},n.handleTouchStart=function(t){n.usingTouch=!0,n.touchStarted||(n.touchStarted=!0,n.touchMoved=!1,n.startX=s(t),n.startY=l(t))},n.handleTouchMove=function(t){if(!n.touchMoved){var e=n.props.tolerance;n.touchMoved=Math.abs(n.startX-s(t))>e||Math.abs(n.startY-l(t))>e}},n.handleTouchCancel=function(){n.touchStarted=n.touchMoved=!1,n.startX=n.startY=0},n.handleTouchEnd=function(){n.touchStarted=!1,!n.touchMoved&&n.props.onPoint&&n.props.onPoint()},r=o,u(n,r)}return i(e,t),e.prototype.componentWillMount=function(){this.usingTouch=!1},e.prototype.render=function(){var t=this.props,e=t.component,o=r(t,["component"]);return o.onClick=this.handleClick,o.onTouchStart=this.handleTouchStart,o.onTouchMove=this.handleTouchMove,o.onTouchCancel=this.handleTouchCancel,o.onTouchEnd=this.handleTouchEnd,delete o.onPoint,delete o.tolerance,p["default"].createElement(e,o)},e}(p["default"].Component);f.propTypes={component:a.PropTypes.oneOfType([a.PropTypes.func,a.PropTypes.string]).isRequired,tolerance:a.PropTypes.number,onPoint:a.PropTypes.func},f.defaultProps={component:"div",tolerance:10},e["default"]=f},function(e,o){e.exports=t}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactPoint=e(require("react")):t.ReactPoint=e(t.React)}(this,function(t){return function(t){function e(n){if(o[n])return o[n].exports;var r=o[n]={exports:{},id:n,loaded:!1};return t[n].call(r.exports,r,r.exports,e),r.loaded=!0,r.exports}var o={};return e.m=t,e.c=o,e.p="",e(0)}([function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.PointTarget=void 0;var r=o(1),u=n(r);e.PointTarget=u["default"]},function(t,e,o){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function u(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}e.__esModule=!0;var a=o(2),i=n(a),l=function(t){return t.touches[0].clientX},s=function(t){return t.touches[0].clientY},p=function(t){function e(){var o,n,c;r(this,e);for(var a=arguments.length,i=Array(a),p=0;p<a;p++)i[p]=arguments[p];return o=n=u(this,t.call.apply(t,[this].concat(i))),n.handleClick=function(){!n.usingTouch&&n.props.onPoint&&n.props.onPoint()},n.handleTouchStart=function(t){n.usingTouch=!0,n.touchStarted||(n.touchStarted=!0,n.touchMoved=!1,n.startX=l(t),n.startY=s(t))},n.handleTouchMove=function(t){if(!n.touchMoved){var e=n.props.tolerance;n.touchMoved=Math.abs(n.startX-l(t))>e||Math.abs(n.startY-s(t))>e}},n.handleTouchCancel=function(){n.touchStarted=n.touchMoved=!1,n.startX=n.startY=0},n.handleTouchEnd=function(){n.touchStarted=!1,!n.touchMoved&&n.props.onPoint&&n.props.onPoint()},c=o,u(n,c)}return c(e,t),e.prototype.componentWillMount=function(){this.usingTouch=!1},e.prototype.render=function(){var t=this.props.children,e=t?i["default"].Children.only(t):i["default"].createElement("button",null);return i["default"].cloneElement(e,{onClick:this.handleClick,onTouchStart:this.handleTouchStart,onTouchMove:this.handleTouchMove,onTouchCancel:this.handleTouchCancel,onTouchEnd:this.handleTouchEnd})},e}(i["default"].Component);p.propTypes={children:a.PropTypes.node,tolerance:a.PropTypes.number,onPoint:a.PropTypes.func},p.defaultProps={tolerance:10},e["default"]=p},function(e,o){e.exports=t}])}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
14414
28
206