From 417806efea328d3028e03b3a230ac97c2fcb5f08 Mon Sep 17 00:00:00 2001 From: Matt Colman Date: Thu, 22 Dec 2016 11:29:33 +1100 Subject: [PATCH] build --- dist/react-tappable.js | 21 +++++++++++++++------ dist/react-tappable.min.js | 2 +- example/dist/bundle.js | 21 +++++++++++++++------ lib/TappableMixin.js | 16 ++++++++++------ lib/getComponent.js | 5 +++++ 5 files changed, 46 insertions(+), 19 deletions(-) diff --git a/dist/react-tappable.js b/dist/react-tappable.js index d36767d..c79185b 100644 --- a/dist/react-tappable.js +++ b/dist/react-tappable.js @@ -213,15 +213,19 @@ var Mixin = { if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || 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(); } - } else if (this.props.allowReactivation) { + } else { if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true @@ -241,7 +245,7 @@ var Mixin = { this.processEvent(event); var afterEndTouch; var movement = this.calculateMovement(this._lastTouch); - if (movement.x <= (this.props.moveThresholdX || this.props.moveThreshold) && movement.y <= (this.props.moveThresholdY || 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 () { var finalParentScrollPos = _this._scrollParents.map(function (node) { @@ -437,6 +441,7 @@ module.exports = function (mixins) { }, this.handlers()); delete newComponentProps.activeDelay; + delete newComponentProps.allowReactivation; delete newComponentProps.classBase; delete newComponentProps.classes; delete newComponentProps.handlers; @@ -445,7 +450,11 @@ module.exports = function (mixins) { delete newComponentProps.onPinchStart; delete newComponentProps.onPinchMove; delete newComponentProps.onPinchEnd; + delete newComponentProps.onDeactivate; + delete newComponentProps.onReactivate; delete newComponentProps.moveThreshold; + delete newComponentProps.moveXThreshold; + delete newComponentProps.moveYThreshold; delete newComponentProps.pressDelay; delete newComponentProps.pressMoveThreshold; delete newComponentProps.preventDefault; diff --git a/dist/react-tappable.min.js b/dist/react-tappable.min.js index 6cabf66..ae00a42 100644 --- a/dist/react-tappable.min.js +++ b/dist/react-tappable.min.js @@ -1 +1 @@ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.Tappable=e()}}(function(){return function e(t,o,s){function i(c,r){if(!o[c]){if(!t[c]){var h="function"==typeof require&&require;if(!r&&h)return h(c,!0);if(n)return n(c,!0);var p=new Error("Cannot find module '"+c+"'");throw p.code="MODULE_NOT_FOUND",p}var l=o[c]={exports:{}};t[c][0].call(l.exports,function(e){var o=t[c][1][e];return i(o?o:e)},l,l.exports,e,t,o,s)}return o[c].exports}for(var n="function"==typeof require&&require,c=0;ce.offsetHeight||e.scrollWidth>e.offsetWidth)&&(this._scrollParents.push(e),this._scrollParentPos.push(e.scrollTop+e.scrollLeft),this._scrollPos.top+=e.scrollTop,this._scrollPos.left+=e.scrollLeft),e=e.parentNode},initTouchmoveDetection:function(){this._touchmoveTriggeredTimes=0},cancelTouchmoveDetection:function(){this._touchmoveDetectionTimeout&&(clearTimeout(this._touchmoveDetectionTimeout),this._touchmoveDetectionTimeout=null,this._touchmoveTriggeredTimes=0)},calculateMovement:function(e){return{x:Math.abs(e.clientX-this._initialTouch.clientX),y:Math.abs(e.clientY-this._initialTouch.clientY)}},detectScroll:function(){for(var e={top:0,left:0},t=0;tthis.props.pressMoveThreshold||t.y>this.props.pressMoveThreshold)&&this.cancelPressDetection(),t.x>(this.props.moveThresholdX||this.props.moveThreshold)||t.y>(this.props.moveThresholdY||this.props.moveThreshold)?this.state.isActive?this.setState({isActive:!1}):this._activeTimeout&&this.clearActiveTimeout():this.props.allowReactivation&&(this.state.isActive||this._activeTimeout||this.setState({isActive:!0}))}else this._initialPinch&&2===e.touches.length&&this.onPinchMove&&(this.onPinchMove(e),e.preventDefault())},onTouchEnd:function(e){var t=this;if(this._initialTouch){this.processEvent(e);var o,s=this.calculateMovement(this._lastTouch);s.x<=(this.props.moveThresholdX||this.props.moveThreshold)&&s.y<=(this.props.moveThresholdY||this.props.moveThreshold)&&this.props.onTap&&(e.preventDefault(),o=function(){var o=t._scrollParents.map(function(e){return e.scrollTop+e.scrollLeft}),s=t._scrollParentPos.some(function(e,t){return e!==o[t]});s||t.props.onTap(e)}),this.endTouch(e,o)}else this.onPinchEnd&&this._initialPinch&&e.touches.length+e.changedTouches.length===2&&(this.onPinchEnd(e),e.preventDefault())},endTouch:function(e,t){this.cancelTouchmoveDetection(),this.cancelPressDetection(),this.clearActiveTimeout(),e&&this.props.onTouchEnd&&this.props.onTouchEnd(e),this._initialTouch=null,this._lastTouch=null,t&&t(),this.state.isActive&&this.setState({isActive:!1})},onMouseDown:function(e){return window._blockMouseEvents?void(window._blockMouseEvents=!1):void(this.props.onMouseDown&&this.props.onMouseDown(e)===!1||(this.processEvent(e),this.initPressDetection(e,this.endMouseEvent),this._mouseDown=!0,this.setState({isActive:!0})))},onMouseMove:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseMove&&this.props.onMouseMove(e))},onMouseUp:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseUp&&this.props.onMouseUp(e),this.props.onTap&&this.props.onTap(e),this.endMouseEvent())},onMouseOut:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseOut&&this.props.onMouseOut(e),this.endMouseEvent())},endMouseEvent:function(){this.cancelPressDetection(),this._mouseDown=!1,this.setState({isActive:!1})},onKeyUp:function(e){this._keyDown&&(this.processEvent(e),this.props.onKeyUp&&this.props.onKeyUp(e),this.props.onTap&&this.props.onTap(e),this._keyDown=!1,this.cancelPressDetection(),this.setState({isActive:!1}))},onKeyDown:function(e){this.props.onKeyDown&&this.props.onKeyDown(e)===!1||e.which!==n&&e.which!==c||this._keyDown||(this.initPressDetection(e,this.endKeyEvent),this.processEvent(e),this._keyDown=!0,this.setState({isActive:!0}))},endKeyEvent:function(){this.cancelPressDetection(),this._keyDown=!1,this.setState({isActive:!1})},cancelTap:function(){this.endTouch(),this._mouseDown=!1},handlers:function(){return{onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onMouseMove:this.onMouseMove,onMouseOut:this.onMouseOut,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp}}};t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,o){(function(o){"use strict";var s=Object.assign||function(e){for(var t=1;te.offsetHeight||e.scrollWidth>e.offsetWidth)&&(this._scrollParents.push(e),this._scrollParentPos.push(e.scrollTop+e.scrollLeft),this._scrollPos.top+=e.scrollTop,this._scrollPos.left+=e.scrollLeft),e=e.parentNode},initTouchmoveDetection:function(){this._touchmoveTriggeredTimes=0},cancelTouchmoveDetection:function(){this._touchmoveDetectionTimeout&&(clearTimeout(this._touchmoveDetectionTimeout),this._touchmoveDetectionTimeout=null,this._touchmoveTriggeredTimes=0)},calculateMovement:function(e){return{x:Math.abs(e.clientX-this._initialTouch.clientX),y:Math.abs(e.clientY-this._initialTouch.clientY)}},detectScroll:function(){for(var e={top:0,left:0},t=0;tthis.props.pressMoveThreshold||t.y>this.props.pressMoveThreshold)&&this.cancelPressDetection(),t.x>(this.props.moveXThreshold||this.props.moveThreshold)||t.y>(this.props.moveYThreshold||this.props.moveThreshold))if(this.state.isActive){if(!this.props.allowReactivation)return this.endTouch(e);this.setState({isActive:!1})}else this._activeTimeout&&this.clearActiveTimeout();else this.state.isActive||this._activeTimeout||this.setState({isActive:!0})}else this._initialPinch&&2===e.touches.length&&this.onPinchMove&&(this.onPinchMove(e),e.preventDefault())},onTouchEnd:function(e){var t=this;if(this._initialTouch){this.processEvent(e);var o,s=this.calculateMovement(this._lastTouch);s.x<=(this.props.moveXThreshold||this.props.moveThreshold)&&s.y<=(this.props.moveYThreshold||this.props.moveThreshold)&&this.props.onTap&&(e.preventDefault(),o=function(){var o=t._scrollParents.map(function(e){return e.scrollTop+e.scrollLeft}),s=t._scrollParentPos.some(function(e,t){return e!==o[t]});s||t.props.onTap(e)}),this.endTouch(e,o)}else this.onPinchEnd&&this._initialPinch&&e.touches.length+e.changedTouches.length===2&&(this.onPinchEnd(e),e.preventDefault())},endTouch:function(e,t){this.cancelTouchmoveDetection(),this.cancelPressDetection(),this.clearActiveTimeout(),e&&this.props.onTouchEnd&&this.props.onTouchEnd(e),this._initialTouch=null,this._lastTouch=null,t&&t(),this.state.isActive&&this.setState({isActive:!1})},onMouseDown:function(e){return window._blockMouseEvents?void(window._blockMouseEvents=!1):void(this.props.onMouseDown&&this.props.onMouseDown(e)===!1||(this.processEvent(e),this.initPressDetection(e,this.endMouseEvent),this._mouseDown=!0,this.setState({isActive:!0})))},onMouseMove:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseMove&&this.props.onMouseMove(e))},onMouseUp:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseUp&&this.props.onMouseUp(e),this.props.onTap&&this.props.onTap(e),this.endMouseEvent())},onMouseOut:function(e){!window._blockMouseEvents&&this._mouseDown&&(this.processEvent(e),this.props.onMouseOut&&this.props.onMouseOut(e),this.endMouseEvent())},endMouseEvent:function(){this.cancelPressDetection(),this._mouseDown=!1,this.setState({isActive:!1})},onKeyUp:function(e){this._keyDown&&(this.processEvent(e),this.props.onKeyUp&&this.props.onKeyUp(e),this.props.onTap&&this.props.onTap(e),this._keyDown=!1,this.cancelPressDetection(),this.setState({isActive:!1}))},onKeyDown:function(e){this.props.onKeyDown&&this.props.onKeyDown(e)===!1||e.which!==n&&e.which!==c||this._keyDown||(this.initPressDetection(e,this.endKeyEvent),this.processEvent(e),this._keyDown=!0,this.setState({isActive:!0}))},endKeyEvent:function(){this.cancelPressDetection(),this._keyDown=!1,this.setState({isActive:!1})},cancelTap:function(){this.endTouch(),this._mouseDown=!1},handlers:function(){return{onTouchStart:this.onTouchStart,onTouchMove:this.onTouchMove,onTouchEnd:this.onTouchEnd,onMouseDown:this.onMouseDown,onMouseUp:this.onMouseUp,onMouseMove:this.onMouseMove,onMouseOut:this.onMouseOut,onKeyDown:this.onKeyDown,onKeyUp:this.onKeyUp}}};t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,o){(function(o){"use strict";var s=Object.assign||function(e){for(var t=1;t this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || 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(); } - } else if (this.props.allowReactivation) { + } else { if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true @@ -227,7 +231,7 @@ var Mixin = { this.processEvent(event); var afterEndTouch; var movement = this.calculateMovement(this._lastTouch); - if (movement.x <= (this.props.moveThresholdX || this.props.moveThreshold) && movement.y <= (this.props.moveThresholdY || 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 () { var finalParentScrollPos = _this._scrollParents.map(function (node) { @@ -421,6 +425,7 @@ module.exports = function (mixins) { }, this.handlers()); delete newComponentProps.activeDelay; + delete newComponentProps.allowReactivation; delete newComponentProps.classBase; delete newComponentProps.classes; delete newComponentProps.handlers; @@ -429,7 +434,11 @@ module.exports = function (mixins) { delete newComponentProps.onPinchStart; delete newComponentProps.onPinchMove; delete newComponentProps.onPinchEnd; + delete newComponentProps.onDeactivate; + delete newComponentProps.onReactivate; delete newComponentProps.moveThreshold; + delete newComponentProps.moveXThreshold; + delete newComponentProps.moveYThreshold; delete newComponentProps.pressDelay; delete newComponentProps.pressMoveThreshold; delete newComponentProps.preventDefault; diff --git a/lib/TappableMixin.js b/lib/TappableMixin.js index 5707777..2414f1c 100644 --- a/lib/TappableMixin.js +++ b/lib/TappableMixin.js @@ -198,15 +198,19 @@ var Mixin = { if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || 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(); } - } else if (this.props.allowReactivation) { + } else { if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true @@ -226,7 +230,7 @@ var Mixin = { this.processEvent(event); var afterEndTouch; var movement = this.calculateMovement(this._lastTouch); - if (movement.x <= (this.props.moveThresholdX || this.props.moveThreshold) && movement.y <= (this.props.moveThresholdY || 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 () { var finalParentScrollPos = _this._scrollParents.map(function (node) { diff --git a/lib/getComponent.js b/lib/getComponent.js index 4918dd1..4c9a9ef 100644 --- a/lib/getComponent.js +++ b/lib/getComponent.js @@ -54,6 +54,7 @@ module.exports = function (mixins) { }, this.handlers()); delete newComponentProps.activeDelay; + delete newComponentProps.allowReactivation; delete newComponentProps.classBase; delete newComponentProps.classes; delete newComponentProps.handlers; @@ -62,7 +63,11 @@ module.exports = function (mixins) { delete newComponentProps.onPinchStart; delete newComponentProps.onPinchMove; delete newComponentProps.onPinchEnd; + delete newComponentProps.onDeactivate; + delete newComponentProps.onReactivate; delete newComponentProps.moveThreshold; + delete newComponentProps.moveXThreshold; + delete newComponentProps.moveYThreshold; delete newComponentProps.pressDelay; delete newComponentProps.pressMoveThreshold; delete newComponentProps.preventDefault;