I'm currently working on implementing a feature to display a list of draggable elements using vue-draggable. These elements are occasionally separated by a fixed element at specified position(s).
My approach so far has involved creating a separate element as needed within the v-for
loop.
<draggable :list="list" class="dragArea" :class="{dragArea: true}"
:options="{group:'people', draggable: '.drag'}" @change="handleChange">
<template v-for="(element, index) in list">
<div class="drag">
{{element.name}}
</div>
<div class="nodrag" v-if="index === 2">Fixed element</div>
</template>
</draggable>
Unfortunately, this approach is causing issues with my app's behavior as the indexes returned by the onChange
event are no longer what I expect. (You can see an example on this jsfiddle)
Could it be that I'm approaching this incorrectly? I have also looked into using the move
prop to disable dragging functionality as suggested here, but the issue persists because I'm utilizing elements from outside the draggable list, I believe.
In our live scenario, the index of the fixed element may vary, if that makes any difference.