Skip to content

Replace/move item? #171

@taujoey

Description

@taujoey

Hi,

I switched my app to this ui-scroll implementation, it works great. Also started using the implemented 'insert' method, which i asked for, really thanks for that, works very well.

About replace.. :)
So, when i not only try to insert a single item, but before the insertion, I also remove another, the list flickers for a little. I think it is understandable, because the list immediately updates after item removal, and a few msec-s later updates again with the inserted item. The problem with it, i cant perform an "item replace" process smoothly.
(Just to make things little more complicated, my use case is 'sorting the items', more specifically dragging an item from one position to another, so in the list's perspective, it is a 'move' process.)

Is there any way to do this replace/move process 'atomically' (like a transaction in a database) ? Calling the remove and insert methods after another just don't do the job perfectly.

Here's a very simple/stupid test code in a button click handler (the methods here are simple wrappers around the ui-scroll's remove and insert methods), which removes a random item, and places it back into the same position:

onclick() {

        let data = this.itemCache[5];

        this.removeFromListById(data.id);
        this.insertIntoListBeforeId(data, this.itemCache[6].id);

        return;
}

Do You have any suggestion, how i can achieve, what i described to you?
Thanks!

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions