qinyan hace 1 año
padre
commit
8e149714a5
Se han modificado 1 ficheros con 12 adiciones y 10 borrados
  1. 12 10
      src/modules/editor/controllers/ScreenshotCtrl/index.ts

+ 12 - 10
src/modules/editor/controllers/ScreenshotCtrl/index.ts

@@ -4,26 +4,28 @@ import { Matrix } from "../SelectCtrl/matrix";
 export class ScreenshotCtrl {
   async snap(options: { element: HTMLElement; ratio?: number }): Promise<Blob> {
     const dom = options.element;
+    const domW = dom.clientWidth;
     // const transferEl = document.querySelector(".transfer") as
     //   | HTMLElement
     //   | undefined;
     // if (transferEl) {
     //   transferEl.style.display = "none";
     // }
-    
+
     //清除dom上的
-    const transform =  dom.style.transform
+    const transform = dom.style.transform;
     if (transform) {
-       const m =  Matrix.createFromMatrixStr(transform);
-        m.tx = 0;
-        m.ty = 0;
-        dom.style.transform = m.getMatrixStr();
+      const m = Matrix.createFromMatrixStr(transform);
+      m.tx = 0;
+      m.ty = 0;
+      dom.style.transform = m.getMatrixStr();
     }
 
-    
     if (options.ratio) {
-
-      const result = await domtoimage.toJpeg(dom);
+      const result = await domtoimage.toJpeg(dom, {
+        style: { overflow: "hidden" },
+        width: domW,
+      });
       const img = await new Promise<HTMLImageElement>((resolve) => {
         const image = new Image();
         image.src = result;
@@ -63,7 +65,7 @@ export class ScreenshotCtrl {
         });
       });
     } else {
-      console.log( "xxxxxxxxxxxxxxxxxx" ,  dom );
+      // console.log("xxxxxxxxxxxxxxxxxx", dom);
       const w = await domtoimage.toBlob(dom);
       if (transform) {
         dom.style.transform = transform;