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

Drag and drop adjustment issue #165

Closed
Salmankhan033 opened this issue Mar 4, 2022 · 4 comments
Closed

Drag and drop adjustment issue #165

Salmankhan033 opened this issue Mar 4, 2022 · 4 comments
Labels
status: waiting reply Waiting a reply from the issue's author type: question

Comments

@Salmankhan033
Copy link

Salmankhan033 commented Mar 4, 2022

When I drop the event on midline means half in one date and half of another date then it can't adjust automatically?
Is there any way that it does not drop the event on the midline (date separate line).

Drawing

@Salmankhan033
Copy link
Author

https://user-images.githubusercontent.com/58082294/156743833-344aed1d-0e2b-462b-be05-4af039299e5a.mov
when I drop the event in the midline that it stop, The Updated API is called after that the Even get API called then the event change their place.
is it possible that it adjust automatically before API call ?

@pdpino
Copy link
Collaborator

pdpino commented Mar 4, 2022

I see, thanks for the video, I'll check this out.

For now, can you send me your code for the onDragEvent callback and the render()? And any hooks involved.

@pdpino
Copy link
Collaborator

pdpino commented Mar 14, 2022

I can reproduce this behavior if I use a time-consuming call in onDragEvent before the events' database (in this case is the state) is updated, for example:

  onDragEvent = async (event, newStartDate, newEndDate) => {
    console.log('Calling some API...');
    const result = await callMyAPI(); // time-consuming call, e.g. takes 1-2 seconds
    console.log('Finished.');

    // Update my local database (for example the component's state: this.setState(...))
    this.updateLocalDB(event, newStartDate, newEventDate);
  };

I can fix it with any of these two options:

// (1) updating the local DB before the time-consuming call
this.updateLocalDB(event, newStartDate, newEventDate);
const result = await callMyAPI();
// or (2) using runAfterInteractions(), see: https://reactnative.dev/docs/interactionmanager
InteractionManager.runAfterInteractions(async () => {
  const result = await callMyAPI();
  // ...
});
this.updateLocalDB(event, newStartDate, newEventDate);

@pdpino pdpino added the status: waiting reply Waiting a reply from the issue's author label Apr 25, 2022
@pdpino
Copy link
Collaborator

pdpino commented Jul 28, 2022

Moving this discussion to #248

@pdpino pdpino closed this as completed Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting reply Waiting a reply from the issue's author type: question
Projects
None yet
Development

No branches or pull requests

2 participants