Skip to content

Commit

Permalink
Prepending card if added ad the beginning
Browse files Browse the repository at this point in the history
  • Loading branch information
adelura committed Apr 5, 2018
1 parent add1e26 commit 4e3756f
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions VueSwing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export default {
data () {
return {
stack: null,
cards: [],
observer: null
}
},
Expand All @@ -24,7 +23,7 @@ export default {
this.stack = Swing.Stack(this.config || {})
let children = [...this.$el.children]
children.forEach(el => {
this.cards.push(this.stack.createCard(el))
this.stack.createCard(el)
})
// Observe changes in DOM
Expand All @@ -47,15 +46,15 @@ export default {
const card = this.stack.getCard(el)
if (card == null) {
this.cards.push(this.stack.createCard(el))
const prepend = Array.from(this.$el.children).indexOf(el) === 0
this.stack.createCard(el, prepend)
}
})
// Remove the card if the element is gone
removedElements.forEach(el => {
const card = this.stack.getCard(el)
if (card != null) {
this.cards.splice(this.cards.indexOf(card), 1)
this.stack.destroyCard(card)
}
})
Expand Down

0 comments on commit 4e3756f

Please sign in to comment.