fix(zhst/meta-cropperImage): cropperImage 透出矩形坐标

This commit is contained in:
NICE CODE BY DEV 2024-05-11 17:17:36 +08:00
parent f9fd6389c4
commit defd87dfc7
21 changed files with 200 additions and 16 deletions

View File

@ -1,6 +1,40 @@
# @zhst/biz # @zhst/biz
## 0.19.2 ## 0.21.1
### Patch Changes
- Updated dependencies
- @zhst/meta@0.20.0
## 0.21.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/hooks@0.13.0
- @zhst/func@0.15.0
- @zhst/icon@0.5.0
- @zhst/meta@0.19.0
## 0.20.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
- @zhst/hooks@0.12.1
- @zhst/meta@0.18.1
## 0.20.0
### Minor Changes
- feat: 重新发版
### Patch Changes ### Patch Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/biz", "name": "@zhst/biz",
"version": "0.19.2", "version": "0.21.1",
"description": "业务库", "description": "业务库",
"keywords": [ "keywords": [
"business", "business",

View File

@ -1,5 +1,23 @@
# @zhst/utils # @zhst/utils
## 0.15.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/request@0.15.0
## 0.14.1
### Patch Changes
- zhst/func: 修改 pxToRem 算法
- @zhst/request@0.14.1
## 0.14.0 ## 0.14.0
### Minor Changes ### Minor Changes

View File

@ -79,7 +79,7 @@ export var getValueByUrl = function getValueByUrl(key, str) {
* @param rootFontSize 根元素大小: 默认16px * @param rootFontSize 根元素大小: 默认16px
*/ */
export var pxToRem = function pxToRem(value, rootFontSize) { export var pxToRem = function pxToRem(value, rootFontSize) {
var fontSize = rootFontSize || parseFloat(document.documentElement.style.fontSize) || 16; var fontSize = rootFontSize || 80 || parseFloat(document.documentElement.style.fontSize);
var valueArr = value.split(' '); var valueArr = value.split(' ');
return valueArr.filter(function (o) { return valueArr.filter(function (o) {
return o; return o;

View File

@ -76,7 +76,7 @@ var getValueByUrl = (key, str) => {
return result; return result;
}; };
var pxToRem = (value, rootFontSize) => { var pxToRem = (value, rootFontSize) => {
const fontSize = rootFontSize || parseFloat(document.documentElement.style.fontSize) || 16; const fontSize = rootFontSize || 80;
const valueArr = value.split(" "); const valueArr = value.split(" ");
return valueArr.filter((o) => o).map((val) => parseFloat(val) / fontSize + "rem").join(" "); return valueArr.filter((o) => o).map((val) => parseFloat(val) / fontSize + "rem").join(" ");
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/func", "name": "@zhst/func",
"version": "0.14.0", "version": "0.15.0",
"description": "函数合集", "description": "函数合集",
"keywords": [ "keywords": [
"hooks" "hooks"

View File

@ -85,7 +85,7 @@ export const getValueByUrl = (key: string, str: string) => {
* @param rootFontSize 根元素大小: 默认16px * @param rootFontSize 根元素大小: 默认16px
*/ */
export const pxToRem = (value: string, rootFontSize?: number) => { export const pxToRem = (value: string, rootFontSize?: number) => {
const fontSize = rootFontSize || parseFloat(document.documentElement.style.fontSize) || 16 const fontSize = rootFontSize || 80 || parseFloat(document.documentElement.style.fontSize)
const valueArr = value.split(' ') const valueArr = value.split(' ')
return valueArr.filter(o => o).map(val => ((parseFloat(val) / fontSize) + 'rem')).join(' ') return valueArr.filter(o => o).map(val => ((parseFloat(val) / fontSize) + 'rem')).join(' ')

View File

@ -1,5 +1,23 @@
# @zhst/hooks # @zhst/hooks
## 0.13.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/func@0.15.0
## 0.12.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
## 0.12.0 ## 0.12.0
### Minor Changes ### Minor Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/hooks", "name": "@zhst/hooks",
"version": "0.12.0", "version": "0.13.0",
"description": "hooks合集", "description": "hooks合集",
"keywords": [ "keywords": [
"hooks" "hooks"

View File

@ -1,5 +1,11 @@
# @zhst/icon # @zhst/icon
## 0.5.0
### Minor Changes
- feat: 修复之前发版错乱问题
## 0.4.0 ## 0.4.0
### Minor Changes ### Minor Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/icon", "name": "@zhst/icon",
"version": "0.4.0", "version": "0.5.0",
"description": "图标库", "description": "图标库",
"keywords": [ "keywords": [
"icon", "icon",

View File

@ -1,6 +1,42 @@
# @zhst/material # @zhst/material
## 0.14.2 ## 0.17.0
### Minor Changes
- fix: cropperImage 透出矩形坐标
### Patch Changes
- Updated dependencies
- @zhst/meta@0.20.0
- @zhst/biz@0.21.1
## 0.16.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/hooks@0.13.0
- @zhst/func@0.15.0
- @zhst/meta@0.19.0
- @zhst/biz@0.21.0
## 0.15.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
- @zhst/biz@0.20.1
- @zhst/hooks@0.12.1
- @zhst/meta@0.18.1
## 0.15.0
### Patch Changes ### Patch Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/material", "name": "@zhst/material",
"version": "0.14.2", "version": "0.17.0",
"description": "物料库", "description": "物料库",
"keywords": [ "keywords": [
"business", "business",

View File

@ -1,5 +1,39 @@
# @zhst/utils # @zhst/utils
## 0.20.0
### Minor Changes
- fix: cropperImage 透出矩形坐标
### Patch Changes
- Updated dependencies
- @zhst/meta@0.20.0
## 0.19.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/hooks@0.13.0
- @zhst/func@0.15.0
- @zhst/icon@0.5.0
- @zhst/meta@0.19.0
## 0.18.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
- @zhst/hooks@0.12.1
- @zhst/meta@0.18.1
## 0.18.0 ## 0.18.0
### Minor Changes ### Minor Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/meta", "name": "@zhst/meta",
"version": "0.18.0", "version": "0.20.0",
"description": "原子组件", "description": "原子组件",
"keywords": [ "keywords": [
"meta", "meta",

View File

@ -212,7 +212,6 @@ export const getOtherExtendRect = (srcRect: Rect, maxW: number, maxH: number, ty
return newRect; return newRect;
}; };
export const getTransformRect = (image: { height: number; width: number; }, transform: { translateX: any; translateY: any; scale: any; rotate: any; }, rect: Rect) => { export const getTransformRect = (image: { height: number; width: number; }, transform: { translateX: any; translateY: any; scale: any; rotate: any; }, rect: Rect) => {
const canvasRect = { const canvasRect = {
x: rect.x, x: rect.x,

View File

@ -9,6 +9,7 @@ import { Cropper, EVENT_CROP_END, EVENT_CROP_START, EVENT_SHAPE_SELECT } from '.
import { Rect } from '../ImageEditor/viewer/shape'; import { Rect } from '../ImageEditor/viewer/shape';
import { checkPointInRect, drawArrowLine, getImageDataByPosition, percentToLength } from './cropperImagehelper'; import { checkPointInRect, drawArrowLine, getImageDataByPosition, percentToLength } from './cropperImagehelper';
import Align from 'rc-align'; import Align from 'rc-align';
import { getTransformRect } from '../BigImagePreview/bigImagePreviewHelper';
interface RectPro extends Rect { interface RectPro extends Rect {
imageRect: string imageRect: string
@ -161,8 +162,10 @@ const CropperImage = forwardRef<CropperImageRefProps, CropperImageProps>((props,
// 矩形 - 结束绘制实践 // 矩形 - 结束绘制实践
cropEndRef.current = addEventListenerWrapper(imageRef.current, EVENT_CROP_END, (event: { detail: any; }) => { cropEndRef.current = addEventListenerWrapper(imageRef.current, EVENT_CROP_END, (event: { detail: any; }) => {
const data = event.detail; const data = event.detail;
const imageRect = getImageDataByPosition({ x: data.left, y: data.top, w: data.width, h: data.height }, { canvas: viewerRef.current.canvas }) const targetPosition = { x: data.left, y: data.top, w: data.width, h: data.height }
onCropEnd?.({ ...data , imageRect, targetTransform }) const imageRect = getImageDataByPosition(targetPosition, { canvas: viewerRef.current.canvas })
const targetData = getTransformRect(_viewer.image, targetTransform, targetPosition)
onCropEnd?.({ ...data , imageRect, targetTransform, targetData })
setIsMove(false) setIsMove(false)
}) })
} else { } else {

View File

@ -1,5 +1,23 @@
# @zhst/request # @zhst/request
## 0.15.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/func@0.15.0
## 0.14.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
## 0.14.0 ## 0.14.0
### Minor Changes ### Minor Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/request", "name": "@zhst/request",
"version": "0.14.0", "version": "0.15.0",
"description": "请求库", "description": "请求库",
"keywords": [ "keywords": [
"request", "request",

View File

@ -1,5 +1,23 @@
# @zhst/slave # @zhst/slave
## 0.11.0
### Minor Changes
- feat: 修复之前发版错乱问题
### Patch Changes
- Updated dependencies
- @zhst/func@0.15.0
## 0.10.1
### Patch Changes
- Updated dependencies
- @zhst/func@0.14.1
## 0.10.0 ## 0.10.0
### Minor Changes ### Minor Changes

View File

@ -1,6 +1,6 @@
{ {
"name": "@zhst/slave", "name": "@zhst/slave",
"version": "0.10.0", "version": "0.11.0",
"description": "微前端子应用方法库", "description": "微前端子应用方法库",
"keywords": [ "keywords": [
"slave", "slave",