Skip to content

Commit

Permalink
update set crop data for image crops
Browse files Browse the repository at this point in the history
attempting to fix #1194

which seems to be an issue with cropper.js
(fengyuanchen/cropperjs#1057)

and ultimately is likely caused by rounding errors

It seems setting individual crop settings instead
of attempting to set them all in one go fixes it,
at least within Twill
  • Loading branch information
13twelve authored and ifox committed Nov 29, 2023
1 parent b37a15a commit 0bb9fc5
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion frontend/js/components/Cropper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,21 @@
},
initCrop: function () {
const crop = this.toNaturalCrop(this.crop)
this.cropper.setData(crop)
// Mike ([email protected]) --
//
// it seems due to rounding errors(?) that sometimes
// the x position can be reset incorrectly
// see: https://github.com/fengyuanchen/cropperjs/issues/1057
//
// from my testing it seems to be a little inconsistent and unpredictable
// I guess you just need for the rounding error to happen
// But, it seems setting the properties individually avoids this...
//
// -- Mike ([email protected])
this.cropper.setData({ x: crop.x })
this.cropper.setData({ y: crop.y })
this.cropper.setData({ width: crop.width })
this.cropper.setData({ height: crop.height })
},
test: function () {
const crop = this.toNaturalCrop({ x: 0, y: 0, width: 380, height: 475 })
Expand Down

0 comments on commit 0bb9fc5

Please sign in to comment.