diff --git a/dist/react-tappable.js b/dist/react-tappable.js index 20470ea..d36767d 100644 --- a/dist/react-tappable.js +++ b/dist/react-tappable.js @@ -97,18 +97,14 @@ var Mixin = { }, onTouchStart: function onTouchStart(event) { - console.log('1'); if (this.props.onTouchStart && this.props.onTouchStart(event) === false) return; - console.log('2'); this.processEvent(event); window._blockMouseEvents = true; if (event.touches.length === 1) { - console.log('3'); this._initialTouch = this._lastTouch = getTouchProps(event.touches[0]); this.initScrollDetection(); this.initPressDetection(event, this.endTouch); this.initTouchmoveDetection(); - console.log('setTimeout', this.props.activeDelay); if (this.props.activeDelay === 0) { this.makeActive(); } else { @@ -120,9 +116,7 @@ var Mixin = { }, makeActive: function makeActive() { - console.log('makeActive'); if (!this.isMounted()) return; - console.log('really'); this.clearActiveTimeout(); this.setState({ isActive: true @@ -219,11 +213,8 @@ var Mixin = { if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - console.log('moving', movement.y); if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || this.props.moveThreshold)) { - console.log('a', this.state.isActive); if (this.state.isActive) { - console.log('d'); this.setState({ isActive: false }); @@ -231,7 +222,6 @@ var Mixin = { this.clearActiveTimeout(); } } else if (this.props.allowReactivation) { - console.log('b'); if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true diff --git a/dist/react-tappable.min.js b/dist/react-tappable.min.js index 49fca4a..6cabf66 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 n(c,r){if(!o[c]){if(!t[c]){var h="function"==typeof require&&require;if(!r&&h)return h(c,!0);if(i)return i(c,!0);var l=new Error("Cannot find module '"+c+"'");throw l.code="MODULE_NOT_FOUND",l}var p=o[c]={exports:{}};t[c][0].call(p.exports,function(e){var o=t[c][1][e];return n(o?o:e)},p,p.exports,e,t,o,s)}return o[c].exports}for(var i="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(),console.log("moving",t.y),t.x>(this.props.moveThresholdX||this.props.moveThreshold)||t.y>(this.props.moveThresholdY||this.props.moveThreshold)?(console.log("a",this.state.isActive),this.state.isActive?(console.log("d"),this.setState({isActive:!1})):this._activeTimeout&&this.clearActiveTimeout()):this.props.allowReactivation&&(console.log("b"),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!==i&&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.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;t this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - console.log('moving', movement.y); if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || this.props.moveThreshold)) { - console.log('a', this.state.isActive); if (this.state.isActive) { - console.log('d'); this.setState({ isActive: false }); @@ -217,7 +208,6 @@ var Mixin = { this.clearActiveTimeout(); } } else if (this.props.allowReactivation) { - console.log('b'); if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true diff --git a/lib/TappableMixin.js b/lib/TappableMixin.js index ba9fd2e..5707777 100644 --- a/lib/TappableMixin.js +++ b/lib/TappableMixin.js @@ -82,18 +82,14 @@ var Mixin = { }, onTouchStart: function onTouchStart(event) { - console.log('1'); if (this.props.onTouchStart && this.props.onTouchStart(event) === false) return; - console.log('2'); this.processEvent(event); window._blockMouseEvents = true; if (event.touches.length === 1) { - console.log('3'); this._initialTouch = this._lastTouch = getTouchProps(event.touches[0]); this.initScrollDetection(); this.initPressDetection(event, this.endTouch); this.initTouchmoveDetection(); - console.log('setTimeout', this.props.activeDelay); if (this.props.activeDelay === 0) { this.makeActive(); } else { @@ -105,9 +101,7 @@ var Mixin = { }, makeActive: function makeActive() { - console.log('makeActive'); if (!this.isMounted()) return; - console.log('really'); this.clearActiveTimeout(); this.setState({ isActive: true @@ -204,11 +198,8 @@ var Mixin = { if (movement.x > this.props.pressMoveThreshold || movement.y > this.props.pressMoveThreshold) { this.cancelPressDetection(); } - console.log('moving', movement.y); if (movement.x > (this.props.moveThresholdX || this.props.moveThreshold) || movement.y > (this.props.moveThresholdY || this.props.moveThreshold)) { - console.log('a', this.state.isActive); if (this.state.isActive) { - console.log('d'); this.setState({ isActive: false }); @@ -216,7 +207,6 @@ var Mixin = { this.clearActiveTimeout(); } } else if (this.props.allowReactivation) { - console.log('b'); if (!this.state.isActive && !this._activeTimeout) { this.setState({ isActive: true