UNPKG

@magnetman103/react-native-zoom-toolkit

Version:

Most complete set of pinch to zoom utilites for React Native

30 lines 1.38 kB
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } import React, { forwardRef } from 'react'; export default function withResumableValidation(Component) { return /*#__PURE__*/forwardRef((props, ref) => { const { minScale, maxScale, children } = props; const childrenCount = React.Children.count(children); if (childrenCount !== 1) { const message = `ResumableZoom expected one child but received ${childrenCount} children`; throw new Error(message); } if (minScale !== undefined && minScale < 1) { throw new Error('minScale must be greater than or equals one'); } const isMaxScaleNumber = typeof maxScale === 'number'; if (isMaxScaleNumber && maxScale < 1) { throw new Error('maxScale must be greater than one, or a SizeVector object in order to infer the max scale'); } if (minScale && isMaxScaleNumber && minScale > maxScale) { throw new Error('minScale must not be greater maxScale'); } return /*#__PURE__*/React.createElement(Component, _extends({}, props, { reference: ref })); }); } //# sourceMappingURL=withResumableValidation.js.map