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

Impossible to past element on certain position #129

Open
EJohnF opened this issue Dec 8, 2017 · 11 comments
Open

Impossible to past element on certain position #129

EJohnF opened this issue Dec 8, 2017 · 11 comments

Comments

@EJohnF
Copy link

EJohnF commented Dec 8, 2017

If order element like: 4-3-1-2
And try to drag element 1 and past to position between 4 and 3 - the displaying doesn't work properly.
See: https://drive.google.com/file/d/1RUCMVS6Yb9jaIHc-JlyABqG0xKZxK-iN/view?usp=sharing

It happens not always, but very often.

@EJohnF
Copy link
Author

EJohnF commented Dec 8, 2017

btw, I was trying to fix it. But don't understand for what do you insert one extra element with height 0.01 in the list?

@EJohnF
Copy link
Author

EJohnF commented Dec 8, 2017

  • there are some unused variables, like (line 376)
this._previouslyHovering = this.state.hovering
this.__activeY = this.panY

EJohnF added a commit to EJohnF/react-native-sortable-listview that referenced this issue Dec 9, 2017
@nihgwu
Copy link
Collaborator

nihgwu commented Dec 9, 2017

Thanks for you contribution, I tried you code in the example but introduces wrong behavior, when I activate a row but don't drag it, there is no placeholder for it anymore

As for the 0.01 question, I didn't write that, but I think that's because the the current wrong behavior when remove a view with LayoutAnimation, that's a known issue from react native, so we have to avoid remove it directly, or you can check the commit history, I believe that was introduced on purpose

@EJohnF
Copy link
Author

EJohnF commented Dec 9, 2017

Ah yes, I re-checked and see that after activations row immidiatly goes for a second to a new position, and after dragging it becomes on the right

@nihgwu
Copy link
Collaborator

nihgwu commented Dec 9, 2017

As for your problem, perhaps there is something wrong with the overlapping check

@EJohnF
Copy link
Author

EJohnF commented Dec 9, 2017

yes, that was my first idea - I added a logs for that part - and it seems it works fine

and at the same time, this.props.hovering in Row render method - wasn't updated properly

@EJohnF
Copy link
Author

EJohnF commented Dec 9, 2017

to be more precise - it is always not possible to past element before the first element (when it's in any position)

@EJohnF
Copy link
Author

EJohnF commented Dec 9, 2017

then, I can suggest this way to solve the problem (while I still don't know the actual reason for the problem)

let hoveringIndex = this.order[this.state.hovering] || this.state.hovering
if (this.order[this.state.hovering] === 0) {
   hoveringIndex = this.order[this.state.hovering]
}

and now it looks like ok:
https://drive.google.com/file/d/177nmOEkRrZ2ZhUZsIONNyVKRQehSA5L-/view?usp=sharing

@nihgwu
Copy link
Collaborator

nihgwu commented Dec 10, 2017

I can't reproduce you problem, but I guess that's related to you data, you are using number as keys?
Then we should

let hoveringIndex = this.order[this.state.hovering]
if (hoveringIndex === undefined) {
   hoveringIndex = this.state.hovering
}

but I think we should use hoveringIndex when we set hovering to number to make the logic more clear, are you interested to work it out 😄

@EJohnF
Copy link
Author

EJohnF commented Dec 10, 2017

you are using number as keys
yes, is it a problem? Usually, it's normal use-case...

@nihgwu
Copy link
Collaborator

nihgwu commented Dec 10, 2017

then if this.order[this.state.hovering] === 0, hoveringIndex will be set to this.state.hovering but actually it should be 0

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