Skip to content

Commit 0728f64

Browse files
committed
migrate to vue.draggable.next
Signed-off-by: Christian Hartmann <chris-hartmann@gmx.de>
1 parent b4a9637 commit 0728f64

3 files changed

Lines changed: 26 additions & 33 deletions

File tree

src/components/Questions/QuestionDropdown.vue

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,22 @@
4444
v-else
4545
v-model="sortedOptions"
4646
class="question__content"
47-
animation="200"
47+
:animation="200"
4848
direction="vertical"
4949
handle=".option__drag-handle"
5050
invert-swap
51-
tag="ul"
51+
tag="transition-group"
52+
:component-data="{
53+
name: isDragging
54+
? 'no-external-transition-on-drag'
55+
: 'options-list-transition',
56+
}"
5257
@change="saveOptionsOrder"
5358
@start="isDragging = true"
5459
@end="isDragging = false">
55-
<TransitionGroup
56-
:name="
57-
isDragging
58-
? 'no-external-transition-on-drag'
59-
: 'options-list-transition'
60-
">
60+
<template #item="{ element: answer, index }">
6161
<!-- Answer text input edit -->
6262
<AnswerInput
63-
v-for="(answer, index) in sortedOptions"
64-
:key="answer.local ? 'option-local' : answer.id"
6563
ref="input"
6664
:answer="answer"
6765
:form-id="formId"
@@ -77,7 +75,7 @@
7775
@move-up="onOptionMoveUp(index)"
7876
@move-down="onOptionMoveDown(index)"
7977
@tabbed-out="checkValidOption" />
80-
</TransitionGroup>
78+
</template>
8179
</Draggable>
8280
</template>
8381

src/components/Questions/QuestionMultiple.vue

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -120,24 +120,21 @@
120120
v-else
121121
v-model="sortedOptions"
122122
class="question__content"
123-
animation="200"
123+
:animation="200"
124124
direction="vertical"
125125
handle=".option__drag-handle"
126126
invert-swap
127-
tag="ul"
127+
tag="transition-group"
128+
:component-data="{
129+
name: isDragging
130+
? 'no-external-transition-on-drag'
131+
: 'options-list-transition',
132+
}"
128133
@change="saveOptionsOrder"
129134
@start="isDragging = true"
130135
@end="isDragging = false">
131-
<TransitionGroup
132-
:name="
133-
isDragging
134-
? 'no-external-transition-on-drag'
135-
: 'options-list-transition'
136-
">
137-
<!-- Answer text input edit -->
136+
<template #item="{ element: answer, index }">
138137
<AnswerInput
139-
v-for="(answer, index) in sortedOptions"
140-
:key="answer.local ? 'option-local' : answer.id"
141138
ref="input"
142139
:answer="answer"
143140
:form-id="formId"
@@ -152,7 +149,7 @@
152149
@move-up="onOptionMoveUp(index)"
153150
@move-down="onOptionMoveDown(index)"
154151
@tabbed-out="checkValidOption" />
155-
</TransitionGroup>
152+
</template>
156153
</Draggable>
157154
<li
158155
v-if="allowOtherAnswer"

src/views/Create.vue

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,22 +116,20 @@
116116
<Draggable
117117
v-model="form.questions"
118118
:animation="200"
119-
tag="ul"
119+
tag="transition-group"
120+
:component-data="{
121+
name: isDragging
122+
? 'no-external-transition-on-drag'
123+
: 'question-list',
124+
}"
120125
handle=".question__drag-handle"
121126
@change="onQuestionOrderChange"
122127
@start="isDragging = true"
123128
@end="isDragging = false">
124-
<transition-group
125-
:name="
126-
isDragging
127-
? 'no-external-transition-on-drag'
128-
: 'question-list'
129-
">
129+
<template #item="{ element: question, index }">
130130
<component
131131
:is="answerTypes[question.type].component"
132-
v-for="(question, index) in form.questions"
133132
ref="questions"
134-
:key="question.id"
135133
v-model="form.questions[index]"
136134
:can-move-down="index < form.questions.length - 1"
137135
:can-move-up="index > 0"
@@ -142,7 +140,7 @@
142140
@delete="deleteQuestion(question.id)"
143141
@move-down="onMoveDown(index)"
144142
@move-up="onMoveUp(index)" />
145-
</transition-group>
143+
</template>
146144
</Draggable>
147145

148146
<!-- Add new questions menu -->

0 commit comments

Comments
 (0)