1 | 'use strict';
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 |
|
7 | var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
8 |
|
9 | var _react = require('react');
|
10 |
|
11 | var _react2 = _interopRequireDefault(_react);
|
12 |
|
13 | var _propTypes = require('prop-types');
|
14 |
|
15 | var _propTypes2 = _interopRequireDefault(_propTypes);
|
16 |
|
17 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
18 |
|
19 | function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
20 |
|
21 | function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
22 |
|
23 | function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
24 |
|
25 | var TouchableArea = function (_React$Component) {
|
26 | _inherits(TouchableArea, _React$Component);
|
27 |
|
28 | function TouchableArea() {
|
29 | var _ref;
|
30 |
|
31 | var _temp, _this, _ret;
|
32 |
|
33 | _classCallCheck(this, TouchableArea);
|
34 |
|
35 | for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
36 | args[_key] = arguments[_key];
|
37 | }
|
38 |
|
39 | return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = TouchableArea.__proto__ || Object.getPrototypeOf(TouchableArea)).call.apply(_ref, [this].concat(args))), _this), _this.handleTouchStart = function (e) {
|
40 | if (!_this.props.scroller || !_this.props.touchable) {
|
41 | return;
|
42 | }
|
43 |
|
44 | _this.props.scroller.doTouchStart(e.touches, e.timeStamp);
|
45 | e.preventDefault();
|
46 | }, _this.handleTouchMove = function (e) {
|
47 | if (!_this.props.scroller || !_this.props.touchable) {
|
48 | return;
|
49 | }
|
50 |
|
51 | _this.props.scroller.doTouchMove(e.touches, e.timeStamp, e.scale);
|
52 | e.preventDefault();
|
53 | }, _this.handleTouchEnd = function (e) {
|
54 | if (!_this.props.scroller || !_this.props.touchable) {
|
55 | return;
|
56 | }
|
57 |
|
58 | _this.props.scroller.doTouchEnd(e.timeStamp);
|
59 | e.preventDefault();
|
60 | }, _temp), _possibleConstructorReturn(_this, _ret);
|
61 | }
|
62 |
|
63 | _createClass(TouchableArea, [{
|
64 | key: 'render',
|
65 | value: function render() {
|
66 | return _react2.default.createElement(
|
67 | 'div',
|
68 | {
|
69 | onTouchStart: this.handleTouchStart,
|
70 | onTouchMove: this.handleTouchMove,
|
71 | onTouchEnd: this.handleTouchEnd,
|
72 | onTouchCancel: this.handleTouchEnd },
|
73 | this.props.children
|
74 | );
|
75 | }
|
76 | }]);
|
77 |
|
78 | return TouchableArea;
|
79 | }(_react2.default.Component);
|
80 |
|
81 | TouchableArea.propTypes = {
|
82 | scroller: _propTypes2.default.object,
|
83 | touchable: _propTypes2.default.bool.isRequired,
|
84 | children: _propTypes2.default.any
|
85 | };
|
86 | TouchableArea.defaultProps = {
|
87 | touchable: true
|
88 | };
|
89 | exports.default = TouchableArea; |
\ | No newline at end of file |