|
@@ -1,4 +1,5 @@
|
|
|
import domtoimage from "dom-to-image";
|
|
|
+import { Matrix } from "../SelectCtrl/matrix";
|
|
|
|
|
|
export class ScreenshotCtrl {
|
|
|
async snap(options: { element: HTMLElement; ratio?: number }): Promise<Blob> {
|
|
@@ -10,7 +11,17 @@ export class ScreenshotCtrl {
|
|
|
// if (transferEl) {
|
|
|
// transferEl.style.display = "none";
|
|
|
// }
|
|
|
+
|
|
|
+ //清除dom上的
|
|
|
+ const transform = dom.style.transform
|
|
|
+ if (transform) {
|
|
|
+ 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 img = await new Promise<HTMLImageElement>((resolve) => {
|
|
@@ -52,9 +63,12 @@ export class ScreenshotCtrl {
|
|
|
});
|
|
|
});
|
|
|
} else {
|
|
|
-
|
|
|
console.log( "xxxxxxxxxxxxxxxxxx" , dom );
|
|
|
- return domtoimage.toBlob(dom);
|
|
|
+ const w = await domtoimage.toBlob(dom);
|
|
|
+ if (transform) {
|
|
|
+ dom.style.transform = transform;
|
|
|
+ }
|
|
|
+ return w;
|
|
|
}
|
|
|
}
|
|
|
}
|