@mce/bigesj 0.15.11 → 0.15.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/convert/cropping.d.ts +1 -1
- package/dist/convert/transform.d.ts +1 -1
- package/dist/index.js +22 -20
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ export interface BigeCropping {
|
|
|
7
7
|
translateY: number;
|
|
8
8
|
zoom?: number;
|
|
9
9
|
}
|
|
10
|
-
export declare function croppingToCropRect(cropping: BigeCropping,
|
|
10
|
+
export declare function croppingToCropRect(cropping: BigeCropping, elWidth: number, elHeight: number): {
|
|
11
11
|
left: number;
|
|
12
12
|
top: number;
|
|
13
13
|
right: number;
|
|
@@ -7,7 +7,7 @@ export interface BigeTransform {
|
|
|
7
7
|
translateY: number;
|
|
8
8
|
zoom?: number;
|
|
9
9
|
}
|
|
10
|
-
export declare function transformToCropRect(transform: BigeTransform,
|
|
10
|
+
export declare function transformToCropRect(transform: BigeTransform, elWidth: number, elHeight: number): {
|
|
11
11
|
left: number;
|
|
12
12
|
top: number;
|
|
13
13
|
right: number;
|
package/dist/index.js
CHANGED
|
@@ -603,16 +603,18 @@ function getStyle(el, clone = false) {
|
|
|
603
603
|
}
|
|
604
604
|
return style;
|
|
605
605
|
}
|
|
606
|
-
function transformToCropRect(transform,
|
|
606
|
+
function transformToCropRect(transform, elWidth, elHeight) {
|
|
607
607
|
const {
|
|
608
608
|
imageWidth,
|
|
609
609
|
imageHeight,
|
|
610
|
-
originWidth: _originWidth =
|
|
611
|
-
originHeight: _originHeight =
|
|
610
|
+
originWidth: _originWidth = elWidth,
|
|
611
|
+
originHeight: _originHeight = elHeight,
|
|
612
612
|
translateX,
|
|
613
613
|
translateY,
|
|
614
614
|
zoom = 1
|
|
615
615
|
} = transform;
|
|
616
|
+
const width = imageWidth * zoom;
|
|
617
|
+
const height = imageHeight * zoom;
|
|
616
618
|
const left = -(imageWidth * (zoom - 1) / 2) + translateX * zoom;
|
|
617
619
|
const top = -(imageHeight * (zoom - 1) / 2) + translateY * zoom;
|
|
618
620
|
const right = left + imageWidth * zoom;
|
|
@@ -620,8 +622,8 @@ function transformToCropRect(transform, width, height) {
|
|
|
620
622
|
return {
|
|
621
623
|
left: -left / width,
|
|
622
624
|
top: -top / height,
|
|
623
|
-
right: -(
|
|
624
|
-
bottom: -(
|
|
625
|
+
right: -(elWidth - right) / width,
|
|
626
|
+
bottom: -(elHeight - bottom) / height
|
|
625
627
|
};
|
|
626
628
|
}
|
|
627
629
|
function convertBackground(el) {
|
|
@@ -667,31 +669,31 @@ function convertBackground(el) {
|
|
|
667
669
|
}
|
|
668
670
|
return background;
|
|
669
671
|
}
|
|
670
|
-
function croppingToCropRect(cropping,
|
|
672
|
+
function croppingToCropRect(cropping, elWidth, elHeight) {
|
|
671
673
|
const {
|
|
672
674
|
imageWidth,
|
|
673
675
|
imageHeight,
|
|
674
|
-
maskWidth =
|
|
675
|
-
maskHeight =
|
|
676
|
+
maskWidth = elWidth,
|
|
677
|
+
maskHeight = elHeight,
|
|
676
678
|
translateX,
|
|
677
679
|
translateY,
|
|
678
680
|
zoom = 1
|
|
679
681
|
} = cropping;
|
|
680
|
-
const
|
|
681
|
-
const
|
|
682
|
-
const distX = (
|
|
683
|
-
const distY = (
|
|
682
|
+
const width = imageWidth * zoom;
|
|
683
|
+
const height = imageHeight * zoom;
|
|
684
|
+
const distX = (width - maskWidth) / 2 - translateX;
|
|
685
|
+
const distY = (height - maskHeight) / 2 - translateY;
|
|
684
686
|
const originX = distX + maskWidth / 2;
|
|
685
687
|
const originY = distY + maskHeight / 2;
|
|
686
|
-
const left = -(
|
|
687
|
-
const top = -(
|
|
688
|
-
const right =
|
|
689
|
-
const bottom =
|
|
688
|
+
const left = -(elWidth / 2 - originX);
|
|
689
|
+
const top = -(elHeight / 2 - originY);
|
|
690
|
+
const right = width - (left + elWidth);
|
|
691
|
+
const bottom = height - (top + elHeight);
|
|
690
692
|
return {
|
|
691
|
-
left: left /
|
|
692
|
-
top: top /
|
|
693
|
-
right: right /
|
|
694
|
-
bottom: bottom /
|
|
693
|
+
left: left / width,
|
|
694
|
+
top: top / height,
|
|
695
|
+
right: right / width,
|
|
696
|
+
bottom: bottom / height
|
|
695
697
|
};
|
|
696
698
|
}
|
|
697
699
|
async function convertImageElementToUrl(el) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mce/bigesj",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.15.
|
|
4
|
+
"version": "0.15.13",
|
|
5
5
|
"description": "Plugin for mce",
|
|
6
6
|
"author": "wxm",
|
|
7
7
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"modern-openxml": "^1.10.1"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"mce": "0.15.
|
|
52
|
+
"mce": "0.15.13"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"mce": "^0"
|