Skip to content

Commit ab288af

Browse files
committed
migrate to vue.draggable.next
Signed-off-by: Christian Hartmann <[email protected]>
1 parent b4a9637 commit ab288af

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

src/components/Questions/QuestionDropdown.vue

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +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"
6463
:key="answer.local ? 'option-local' : answer.id"
6564
ref="input"
6665
:answer="answer"
@@ -77,7 +76,7 @@
7776
@move-up="onOptionMoveUp(index)"
7877
@move-down="onOptionMoveDown(index)"
7978
@tabbed-out="checkValidOption" />
80-
</TransitionGroup>
79+
</template>
8180
</Draggable>
8281
</template>
8382

src/components/Questions/QuestionMultiple.vue

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -120,23 +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"
140138
:key="answer.local ? 'option-local' : answer.id"
141139
ref="input"
142140
:answer="answer"
@@ -152,7 +150,7 @@
152150
@move-up="onOptionMoveUp(index)"
153151
@move-down="onOptionMoveDown(index)"
154152
@tabbed-out="checkValidOption" />
155-
</TransitionGroup>
153+
</template>
156154
</Draggable>
157155
<li
158156
v-if="allowOtherAnswer"

src/views/Create.vue

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,20 +116,19 @@
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"
134133
:key="question.id"
135134
v-model="form.questions[index]"
@@ -142,7 +141,7 @@
142141
@delete="deleteQuestion(question.id)"
143142
@move-down="onMoveDown(index)"
144143
@move-up="onMoveUp(index)" />
145-
</transition-group>
144+
</template>
146145
</Draggable>
147146

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

0 commit comments

Comments
 (0)