@@ -29880,30 +29880,37 @@ var Repeatable = (_temp2 = _class = function (_PureComponent) {
2988029880 args[_key] = arguments[_key];
2988129881 }
2988229882
29883- return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Repeatable.__proto__ || Object.getPrototypeOf(Repeatable)).call.apply(_ref, [this].concat(args))), _this), _this.repeatDelayTimer = null, _this.repeatIntervalTimer = null, _this.acquireTimer = function () {
29883+ return _ret = (_temp = (_this = _possibleConstructorReturn(this, (_ref = Repeatable.__proto__ || Object.getPrototypeOf(Repeatable)).call.apply(_ref, [this].concat(args))), _this), _this.repeatDelayTimer = null, _this.repeatIntervalTimer = null, _this.repeatAmount = 0, _this. acquireTimer = function () {
2988429884 var repeatDelay = Math.max(Number(_this.props.repeatDelay) || 0, 0);
2988529885 var repeatInterval = Math.max(Number(_this.props.repeatInterval) || 0, 0);
2988629886 var repeatCount = Math.max(Number(_this.props.repeatCount) || 0, 0);
2988729887
29888+ _this.repeatAmount = 0;
2988829889 _this.releaseTimer();
2988929890
29890- var repeatAmount = 0;
2989129891 _this.repeatDelayTimer = setTimeout(function () {
29892+ if (repeatCount > 0 && _this.repeatAmount >= repeatCount) {
29893+ return;
29894+ }
29895+
29896+ _this.repeatAmount++;
29897+
2989229898 if (typeof _this.props.onHoldStart === 'function') {
2989329899 _this.props.onHoldStart();
2989429900 }
2989529901 if (typeof _this.props.onHold === 'function') {
29896- if (!repeatCount || repeatAmount < repeatCount) {
29897- ++repeatAmount;
29898- _this.props.onHold();
29899- }
29902+ _this.props.onHold();
2990029903 }
29904+
2990129905 _this.repeatIntervalTimer = setInterval(function () {
29902- if (_this.repeatIntervalTimer && typeof _this.props.onHold === 'function') {
29903- if (!repeatCount || repeatAmount < repeatCount) {
29904- ++repeatAmount;
29905- _this.props.onHold();
29906- }
29906+ if (repeatCount > 0 && _this.repeatAmount >= repeatCount) {
29907+ return;
29908+ }
29909+
29910+ _this.repeatAmount++;
29911+
29912+ if (typeof _this.props.onHold === 'function') {
29913+ _this.props.onHold();
2990729914 }
2990829915 }, repeatInterval);
2990929916 }, repeatDelay);
@@ -29922,6 +29929,7 @@ var Repeatable = (_temp2 = _class = function (_PureComponent) {
2992229929 _createClass(Repeatable, [{
2992329930 key: 'componentWillUnmount',
2992429931 value: function componentWillUnmount() {
29932+ this.repeatAmount = 0;
2992529933 this.releaseTimer();
2992629934 }
2992729935 }, {
@@ -29941,17 +29949,18 @@ var Repeatable = (_temp2 = _class = function (_PureComponent) {
2994129949 props = _objectWithoutProperties(_props, ['repeatDelay', 'repeatInterval', 'repeatCount', 'onPress', 'onHoldStart', 'onHold', 'onHoldEnd', 'onRelease']);
2994229950
2994329951 var release = function release(event) {
29944- if (typeof _this2.props.onRelease === 'function') {
29945- _this2.props.onRelease(event);
29952+ if (_this2.repeatAmount > 0) {
29953+ if (typeof _this2.props.onHoldEnd === 'function') {
29954+ _this2.props.onHoldEnd();
29955+ }
2994629956 }
2994729957
29958+ _this2.repeatAmount = 0;
2994829959 _this2.releaseTimer();
2994929960
29950- setTimeout(function () {
29951- if (typeof _this2.props.onHoldEnd === 'function') {
29952- _this2.props.onHoldEnd();
29953- }
29954- }, 0);
29961+ if (typeof _this2.props.onRelease === 'function') {
29962+ _this2.props.onRelease(event);
29963+ }
2995529964 };
2995629965
2995729966 var press = function press(event) {
@@ -29989,7 +29998,7 @@ var Repeatable = (_temp2 = _class = function (_PureComponent) {
2998929998 // The time interval (in milliseconds) on how often to trigger a hold action.
2999029999 repeatInterval: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
2999130000
29992- // The number of times the hold action will take place.
30001+ // The number of times the hold action will take place. A zero value will disable the repeat counter.
2999330002 repeatCount: _propTypes2.default.oneOfType([_propTypes2.default.number, _propTypes2.default.string]),
2999430003
2999530004 // Callback fired when the mousedown or touchstart event is triggered.
@@ -30008,7 +30017,8 @@ var Repeatable = (_temp2 = _class = function (_PureComponent) {
3000830017 onRelease: _propTypes2.default.func
3000930018}, _class.defaultProps = {
3001030019 repeatDelay: 500,
30011- repeatInterval: 32
30020+ repeatInterval: 32,
30021+ repeatCount: 0
3001230022}, _temp2);
3001330023exports.default = Repeatable;
3001430024
@@ -30703,4 +30713,4 @@ _reactDom2.default.render(_react2.default.createElement(App, null), document.get
3070330713/***/ })
3070430714
3070530715/******/ });
30706- //# sourceMappingURL=bundle.js.map?7b6bbb7b632eb718a840
30716+ //# sourceMappingURL=bundle.js.map?f0e503d902d5a2530239
0 commit comments