Skip to content

Commit

Permalink
fix #14 wait for transition before remove model
Browse files Browse the repository at this point in the history
  • Loading branch information
Astray-git committed Oct 9, 2016
1 parent ca309f8 commit af6a2e4
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ if (!dragula) {
throw new Error('[vue-dragula] cannot locate dragula.')
}

const raf = window.requestAnimationFrame
const waitForTransition = raf
? function (fn) {
raf(() => {
raf(fn)
})
}
: function (fn) {
window.setTimeout(fn, 50)
}

class DragulaService {
constructor (Vue) {
this.bags = [] // bag store
Expand Down Expand Up @@ -87,7 +98,9 @@ class DragulaService {
let dropElmModel = notCopy ? sourceModel[dragIndex] : JSON.parse(JSON.stringify(sourceModel[dragIndex]))

if (notCopy) {
sourceModel.splice(dragIndex, 1)
waitForTransition(() => {
sourceModel.splice(dragIndex, 1)
})
}
targetModel.splice(dropIndex, 0, dropElmModel)
drake.cancel(true)
Expand Down

0 comments on commit af6a2e4

Please sign in to comment.