Skip to content

Commit 223e67d

Browse files
committed
fix #14 wait for transition before remove model
1 parent ca309f8 commit 223e67d

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/service.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ if (!dragula) {
44
throw new Error('[vue-dragula] cannot locate dragula.')
55
}
66

7+
const raf = window.requestAnimationFrame
8+
const waitForTransition = raf
9+
? function (fn) {
10+
raf(() => {
11+
raf(fn)
12+
})
13+
}
14+
: function (fn) {
15+
window.setTimeout(fn, 50)
16+
}
17+
718
class DragulaService {
819
constructor (Vue) {
920
this.bags = [] // bag store
@@ -87,7 +98,9 @@ class DragulaService {
8798
let dropElmModel = notCopy ? sourceModel[dragIndex] : JSON.parse(JSON.stringify(sourceModel[dragIndex]))
8899

89100
if (notCopy) {
90-
sourceModel.splice(dragIndex, 1)
101+
waitForTransition(() => {
102+
sourceModel.splice(dragIndex, 1)
103+
})
91104
}
92105
targetModel.splice(dropIndex, 0, dropElmModel)
93106
drake.cancel(true)

src/vue-dragula.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ export default function (Vue) {
4343
update (newValue, oldValue) {
4444
if (!newValue) { return }
4545

46+
const bagName = this.params.bag
47+
if (bagName !== undefined && bagName.length !== 0) {
48+
name = bagName
49+
}
50+
const bag = service.find(name)
51+
drake = bag.drake
4652
if (!drake.models) {
4753
drake.models = []
4854
}

0 commit comments

Comments
 (0)