javascript - VueJs draggable sortable cancel adding element without cancel the drag preview -


i working draggable , sortable vuejs, , trying accomplish thing, basicly have 2 lists, first 1 list sections (table, paragraph ...) second 1 building blocks sections, basicly flow need is, drag element list1 list2, but don't add element important because need open modal first set properties of element added, , add futureindex.

at moment have solution can need, need understand how cancel addition of element without struggling preview of dragging, preview mean this:

enter image description here

i wanna see adition of elment @ middle.

so first list have done this:

<draggable v-model="sectionlist" class="dragarea" @end="changeview()" :move="moveitem" :options="{group:{ name:'sections',pull:'clone',put:false }}">     <div v-for="(section, index) in sectionlist"  class="card card-color list-complete-item">         <div class="card-block">             <h4 class="card-title text-center">{{section.text}}</h4>         </div>     </div> </draggable>  methods: {     addparagraph() {         this.$set(this.paragraph, 'key', this.key);         this.$set(this.paragraph, 'text', this.text);         this.$set(this.paragraph, 'fontsize', this.fontsize);         this.$store.commit("appendtodocument", this.paragraph)     },     changeview: function () {         this.$store.commit("changecurrentview", this.sectionlist[this.dragedindex].component);         this.show();     },     show() {         this.$modal.show('modalsection');     },     hide() {         this.$modal.hide('modalsection');     },     currentindex(evt) {         console.log(evt.draggedcontext.index);     },     moveitem(evt) { // future index of modal draged         console.log(evt.draggedcontext.futureindex);         this.dragedindex = evt.draggedcontext.index;     } }, 

the second list not important, long can understand post, how move item without adding , see preview. had added return false @ end can't see preview , can't drag elements between same list.

any this?

the sortable itself, library vue.draggable based on, doesn't have drop event handler (link), can started: https://jsfiddle.net/94z81596/10/. key idea making use of change handler:

<draggable    id="list2"    class="dragarea"    :options="{group:'people'}"    @change="afteradd"   :list="gdocument"> ... </draggable> 

the solution can simpler, can keep track of futureindex (and save placeholder) , return false in checkmove , manually insert item through vuex. current solution doing same thing.

but intended keep preview user can know they're inserting element. did work clean list doing this:

state.document = state.document.filter((item) => item.value); 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -