|
@@ -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;
|