@mce/bigesj 0.15.12 → 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.
@@ -7,7 +7,7 @@ export interface BigeCropping {
7
7
  translateY: number;
8
8
  zoom?: number;
9
9
  }
10
- export declare function croppingToCropRect(cropping: BigeCropping, width: number, height: number): {
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, width: number, height: number): {
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, width, height) {
606
+ function transformToCropRect(transform, elWidth, elHeight) {
607
607
  const {
608
608
  imageWidth,
609
609
  imageHeight,
610
- originWidth: _originWidth = width,
611
- originHeight: _originHeight = height,
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: -(width - right) / width,
624
- bottom: -(height - bottom) / height
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, width, height) {
672
+ function croppingToCropRect(cropping, elWidth, elHeight) {
671
673
  const {
672
674
  imageWidth,
673
675
  imageHeight,
674
- maskWidth = width,
675
- maskHeight = height,
676
+ maskWidth = elWidth,
677
+ maskHeight = elHeight,
676
678
  translateX,
677
679
  translateY,
678
680
  zoom = 1
679
681
  } = cropping;
680
- const cvsWidth = imageWidth * zoom;
681
- const cvsHeight = imageHeight * zoom;
682
- const distX = (cvsWidth - maskWidth) / 2 - translateX;
683
- const distY = (cvsHeight - maskHeight) / 2 - translateY;
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 = -(width / 2 - originX);
687
- const top = -(height / 2 - originY);
688
- const right = cvsWidth - (left + width);
689
- const bottom = cvsHeight - (top + height);
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 / cvsWidth,
692
- top: top / cvsHeight,
693
- right: right / cvsWidth,
694
- bottom: bottom / cvsHeight
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.12",
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.12"
52
+ "mce": "0.15.13"
53
53
  },
54
54
  "peerDependencies": {
55
55
  "mce": "^0"