react-cropper
Advanced tools
Comparing version
@@ -80,3 +80,21 @@ import React, { useRef, useEffect } from 'react'; | ||
var combinedRef = useCombinedRefs(ref, innerRef); | ||
/** | ||
* Invoke zoomTo method when cropper is set and zoomTo prop changes | ||
*/ | ||
useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof zoomTo === 'number') { | ||
combinedRef.current.cropper.zoomTo(zoomTo); | ||
} | ||
}, [props.zoomTo]); | ||
/** | ||
* re-render when src changes | ||
*/ | ||
useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof src !== 'undefined') { | ||
combinedRef.current.cropper.reset().clear().replace(src); | ||
} | ||
}, [src]); | ||
useEffect(function () { | ||
if (combinedRef.current !== null) { | ||
@@ -99,11 +117,2 @@ var cropper = new Cropper(combinedRef.current, __assign(__assign({ dragMode: dragMode }, rest), { ready: function (e) { | ||
}, [combinedRef]); | ||
/** | ||
* re-render when src changes | ||
*/ | ||
useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof src !== 'undefined') { | ||
combinedRef.current.cropper.reset().clear().replace(src); | ||
} | ||
}, [src]); | ||
return (React.createElement("div", { style: style, className: className }, | ||
@@ -110,0 +119,0 @@ React.createElement("img", { crossOrigin: crossOrigin, src: src, alt: alt, style: { opacity: 0, maxWidth: '100%' }, ref: combinedRef }))); |
@@ -89,3 +89,21 @@ 'use strict'; | ||
var combinedRef = useCombinedRefs(ref, innerRef); | ||
/** | ||
* Invoke zoomTo method when cropper is set and zoomTo prop changes | ||
*/ | ||
React.useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof zoomTo === 'number') { | ||
combinedRef.current.cropper.zoomTo(zoomTo); | ||
} | ||
}, [props.zoomTo]); | ||
/** | ||
* re-render when src changes | ||
*/ | ||
React.useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof src !== 'undefined') { | ||
combinedRef.current.cropper.reset().clear().replace(src); | ||
} | ||
}, [src]); | ||
React.useEffect(function () { | ||
if (combinedRef.current !== null) { | ||
@@ -108,11 +126,2 @@ var cropper = new Cropper__default['default'](combinedRef.current, __assign(__assign({ dragMode: dragMode }, rest), { ready: function (e) { | ||
}, [combinedRef]); | ||
/** | ||
* re-render when src changes | ||
*/ | ||
React.useEffect(function () { | ||
var _a; | ||
if (((_a = combinedRef.current) === null || _a === void 0 ? void 0 : _a.cropper) && typeof src !== 'undefined') { | ||
combinedRef.current.cropper.reset().clear().replace(src); | ||
} | ||
}, [src]); | ||
return (React__default['default'].createElement("div", { style: style, className: className }, | ||
@@ -119,0 +128,0 @@ React__default['default'].createElement("img", { crossOrigin: crossOrigin, src: src, alt: alt, style: { opacity: 0, maxWidth: '100%' }, ref: combinedRef }))); |
{ | ||
"name": "react-cropper", | ||
"version": "2.1.7", | ||
"version": "2.1.8-0", | ||
"description": "Cropper as React Component", | ||
@@ -65,3 +65,3 @@ "main": "dist/react-cropper.umd.js", | ||
"@typescript-eslint/eslint-plugin": "^4.0.0", | ||
"@typescript-eslint/parser": "^3.2.0", | ||
"@typescript-eslint/parser": "^4.15.1", | ||
"babel-jest": "^26.2.2", | ||
@@ -91,3 +91,3 @@ "babel-preset-react-app": "^10.0.0", | ||
"rollup-plugin-postcss": "^3.1.2", | ||
"rollup-plugin-typescript2": "^0.29.0", | ||
"rollup-plugin-typescript2": "^0.30.0", | ||
"tslib": "^2.0.0", | ||
@@ -94,0 +94,0 @@ "typescript": "^4.0.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
91684
2.84%957
2.46%1
Infinity%