From e1f31908b80e8f3c966125139a887337dd72f299 Mon Sep 17 00:00:00 2001 From: Raul Rene Lepsa Date: Thu, 21 Dec 2017 18:08:34 +0200 Subject: [PATCH 1/2] Avoid swallowing children's ref property, if it's set. Fixes #83 --- src/Hammer.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Hammer.js b/src/Hammer.js index 22ea632..850eb69 100644 --- a/src/Hammer.js +++ b/src/Hammer.js @@ -137,8 +137,11 @@ export default class HammerComponent extends React.Component { }, this); var self = this; - props.ref = function(domElement) { - if (self.props.ref) { + props.ref = function (domElement) { + if (self.props.children && self.props.children.ref) { + // If the child has the ref set, call the child's ref method + self.props.children.ref(domElement); + } else if (self.props.ref) { self.props.ref(domElement); } self.domElement = domElement; From bf23ac2800ccc771490b20e78e61bb87445203fa Mon Sep 17 00:00:00 2001 From: Xianqiao Wang Date: Fri, 19 Jan 2018 16:00:10 +0800 Subject: [PATCH 2/2] update build --- dist/react-hammerjs.es.js | 5 +- dist/react-hammerjs.js | 5 +- dist/react-hammerjs.min.js | 2 +- lib/Hammer.js | 5 +- package-lock.json | 4099 ++++++++++++++++++++++++++++++++++++ 5 files changed, 4112 insertions(+), 4 deletions(-) create mode 100644 package-lock.json diff --git a/dist/react-hammerjs.es.js b/dist/react-hammerjs.es.js index b25fc96..c9041db 100644 --- a/dist/react-hammerjs.es.js +++ b/dist/react-hammerjs.es.js @@ -149,7 +149,10 @@ var HammerComponent = function (_React$Component) { var self = this; props.ref = function (domElement) { - if (self.props.ref) { + if (self.props.children && self.props.children.ref) { + // If the child has the ref set, call the child's ref method + self.props.children.ref(domElement); + } else if (self.props.ref) { self.props.ref(domElement); } self.domElement = domElement; diff --git a/dist/react-hammerjs.js b/dist/react-hammerjs.js index 4b6127d..331b4f5 100644 --- a/dist/react-hammerjs.js +++ b/dist/react-hammerjs.js @@ -155,7 +155,10 @@ var HammerComponent = function (_React$Component) { var self = this; props.ref = function (domElement) { - if (self.props.ref) { + if (self.props.children && self.props.children.ref) { + // If the child has the ref set, call the child's ref method + self.props.children.ref(domElement); + } else if (self.props.ref) { self.props.ref(domElement); } self.domElement = domElement; diff --git a/dist/react-hammerjs.min.js b/dist/react-hammerjs.min.js index 2c15426..f9d4d5a 100644 --- a/dist/react-hammerjs.min.js +++ b/dist/react-hammerjs.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("prop-types"),require("react")):"function"==typeof define&&define.amd?define(["prop-types","react"],t):e.Hammer=t(e.PropTypes,e.React)}(this,function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}function i(e,t){t.hasOwnProperty("vertical")&&console.warn("vertical is deprecated, please use `direction` instead");var n=t.direction;if(n||t.hasOwnProperty("vertical")){var o=n||(t.vertical?"DIRECTION_ALL":"DIRECTION_HORIZONTAL");e.get("pan").set({direction:c[o]}),e.get("swipe").set({direction:c[o]})}t.options&&Object.keys(t.options).forEach(function(n){if("recognizers"===n)Object.keys(t.options.recognizers).forEach(function(n){var o=e.get(n);o.set(t.options.recognizers[n]),t.options.recognizers[n].requireFailure&&o.requireFailure(t.options.recognizers[n].requireFailure)},this);else{var o={};o[n]=t.options[n],e.set(o)}},this),t.recognizeWith&&Object.keys(t.recognizeWith).forEach(function(n){e.get(n).recognizeWith(t.recognizeWith[n])},this),Object.keys(t).forEach(function(n){var o=p[n];o&&(e.off(o),e.on(o,t[n]))})}e=e&&e.hasOwnProperty("default")?e.default:e,t=t&&t.hasOwnProperty("default")?t.default:t;var a=function(){function e(e,t){for(var n=0;n