react-native-sortable-listview icon indicating copy to clipboard operation
react-native-sortable-listview copied to clipboard

Impossible to past element on certain position

Open EJohnF opened this issue 7 years ago • 11 comments

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 avatar Dec 08 '17 23:12 EJohnF

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 avatar Dec 08 '17 23:12 EJohnF

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

EJohnF avatar Dec 08 '17 23:12 EJohnF

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

nihgwu avatar Dec 09 '17 06:12 nihgwu

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

EJohnF avatar Dec 09 '17 08:12 EJohnF

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

nihgwu avatar Dec 09 '17 08:12 nihgwu

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 avatar Dec 09 '17 09:12 EJohnF

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

EJohnF avatar Dec 09 '17 16:12 EJohnF

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

EJohnF avatar Dec 09 '17 17:12 EJohnF

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 😄

nihgwu avatar Dec 10 '17 11:12 nihgwu

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

EJohnF avatar Dec 10 '17 11:12 EJohnF

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

nihgwu avatar Dec 10 '17 11:12 nihgwu