-
Notifications
You must be signed in to change notification settings - Fork 588
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
How it's work with nested items? #1
Comments
i have fork this one for some experiments, you can follow it https://github.com/Leadaxe/vue-virtual-scroll-list/blob/master/src/index.js |
@Leadaxe I think that the list For your issue example, you want to use I've seen the <template>
<virtualList ref="vlist" :size="50" :remain="20">
<item v-for="(item, index) of items"
:item="item"
:key="item.id"
:index="index"
/>
</virtualList>
</template>
<script>
import item from '../item.vue';
import sortable from 'sortablejs';
import virtualList from 'vue-virtual-scroll-list';
export default {
name: 'test',
data () {
return {
items: [...]
}
},
mounted () {
let listEl = this.$refs.vlist.$el.firstElementChild;
// update items order.
sortable.create(listEl, {
onSort: (evt) => {
let { newIndex, oldIndex } = evt;
let newVal = this.items[newIndex];
let oldVal = this.items[oldIndex];
this.items.splice(newIndex, 1, oldVal);
this.items.splice(oldIndex, 1, newVal);
}
});
}
}
</script> Or you have other idea, hope to share with me. |
I think about this approach let newVal = this.items[newIndex]; But will be index only of visible elements, that is true? You logic work with vue slots and it work very good. But if you can refactor you code for work with somethink like that <virtualList :items = items in this case we can used nested component like we use it in another components like vuedraggable. if it possible, it will be good |
The In my original intention, |
Hi @tangbc Perhaps things have changed since then? Any idea on how to get either vuedraggable or sortablejs to work with virtualList? |
I created a Vue component which combines SortableJS/Vue.Draggable and tangbc/vue-virtual-scroll-list together, although this issue was very old. https://github.com/p-baleine/vue-draggable-virtual-scroll-list Anyway, I am profoundly grateful to both of your awesome libraries! |
Now 2.0 doesn't use nest item, is there still has problem when handling drag inside item component? |
There are no problems if I handle dragging and updating of data on a single list. The following is an example that uses v2.0 and is based on your example which uses SortableJS/Sortable. But, in addition to handling dragging of data on a single list, I want to handle dragging of data between multiple lists and it is obviously not so simple with vue-virtual-scroll-list and Sortable. vuedraggable supports dragging between multiple lists. I think that, if I want the dragging feature that supports multiple virtual-list, it is preferable to use vuedraggable instead of implementing such features by myself, due to the popularity and the stability of vuedraggable. So I created vue-draggable-virtual-scroll-list.
|
I would like to do something like that:
how can i do that? help me plz
The text was updated successfully, but these errors were encountered: