Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The cropperImage.$ready()is called without it being ready. #1168

Open
genu opened this issue Apr 30, 2024 · 1 comment
Open

The cropperImage.$ready()is called without it being ready. #1168

genu opened this issue Apr 30, 2024 · 1 comment

Comments

@genu
Copy link

genu commented Apr 30, 2024

Describe the bug
I think there is a weird race condition happening when trying to set initia values after image has loaded.

I'm implementing V2 in vue as so:

onMounted(async () => {
  await nextTick();

  await cropperImage.value!.$ready();
  cropperImage.value!.$center('contain').$zoom(-0.1); // <--- Doesn't work
  setTimeout(() => {
    cropperImage.value!.$center('contain').$zoom(-0.1); <-- // Works
  }, 0);
});

Expected behavior
I expect that after calling $ready I should be able to performa any action on image

Desktop (please complete the following information):

  • OS: MacOS
  • Browser safar
@fengyuanchen
Copy link
Owner

fengyuanchen commented May 4, 2024

How about this:

onMounted(async () => {
  await nextTick();
  await cropperImage.value!.$ready();
  await nextTick(); // Wait for next tick
  cropperImage.value!.$center('contain').$zoom(-0.1); // <--- Does it work?
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants