Skip to content

Commit

Permalink
fix: 修改变量名
Browse files Browse the repository at this point in the history
  • Loading branch information
mengdu committed Mar 26, 2024
1 parent 354f3a4 commit b9f7b8a
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/cropper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,19 @@ export default function ImageCropper(props: ImageCropperProps) {
return
}

const target = document.createElement('canvas')
target.width = data.area.w
target.height = data.area.h
const targetctx = target.getContext('2d')!
targetctx.drawImage(imgEl.current,
const canvas = document.createElement('canvas')
canvas.width = data.area.w
canvas.height = data.area.h
const ctx = canvas.getContext('2d')!
ctx.drawImage(
imgEl.current,
(data.area.x - data.img.x) / data.img.scale,
(data.area.y - data.img.y) / data.img.scale,
data.area.w / data.img.scale,
data.area.h / data.img.scale,
0, 0, data.area.w, data.area.h)
target.toBlob((e) => {
0, 0, data.area.w, data.area.h
)
canvas.toBlob((e) => {
data.blob = e
props.onComplete!(data)
}, 'image/png', '1')
Expand Down

0 comments on commit b9f7b8a

Please sign in to comment.