fengyuanchen/cropperjs

strange x value when call setData

Closed this issue · 1 comments

Describe the bug
using vue3 and encapsulate cropper into a component, calling setData after init, the response'x value is -1.8989449817236961e-13

To Reproduce
Steps to reproduce the behavior:

  1. using vue3, using MyComponent, the image is base64
    <MyComponent v-if="img" :image="img" style="width: 800px" />
  2. MyComponent will init cropper when mounted, and the options is like below:
new Cropper(img.value, {
      background: false,
      guides: false,
      movable: false,
      viewMode: 2,
      dragMode: 'move',
      autoCropArea: 1,
      modal: false,
      scalable: false,
      zoomable: false,
      cropBoxMovable: false,
    });
  };
  1. calling setData func, the response is:
{x: -1.8989449817236961e-13, 
y: 0, 
width: 2688, 
height: 1520, 
rotate: 0}
  1. Then I pulled the drag line on the left back and forth, call the setData, the response's x value is become normal 0

Expected behavior
the x value of setData'response should be correct after init

Screenshots
image

Desktop (please complete the following information):

  • OS: [windows11]
  • Browser [edge]
  • Version [126.0.2592.113 ]

Additional context

Only viewMode: 0 supports your case.