Skip to content

Commit

Permalink
wip(oimo): cancelable 'n nextTick
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Oct 9, 2017
1 parent 74b7ff3 commit 608f78d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ Vue.use(VueThreejs)
- [ ] global-control
- [ ] Physical engine
- [x] movement(a/v/pos/ra/rv/rot)/mass(m/F)
- [ ] gravity(G/r)/collision
- [x] gravity(G/r)/collision/oimo
- [ ] circular-motion/centripetal-force
- [ ] Unit test
- [x] karma/mocha/phantom
- [ ] avoriaz/ava
Expand Down
1 change: 1 addition & 0 deletions src/components/Base.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default {
let e = new CustomEvent(name, {
detail,
bubbles: true,
cancelable: true,
...options
})
return this.$el.dispatchEvent(e)
Expand Down
8 changes: 6 additions & 2 deletions src/oimo/OimoBody.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export default {
let body = this.world.add(opts)
body.connectMesh(this.curObj)
this.body = body
this.dispatchEvent('vm-oimo-body', this)
// If you want to wait until the entire view has been rendered
// https://vuejs.org/v2/api/#mounted
this.$nextTick(() => {
this.dispatchEvent('vm-oimo-body', body)
})
},
beforeDestroy () {
Expand Down
15 changes: 5 additions & 10 deletions src/oimo/SpaceObject.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div @vm-oimo-body="handleBodyVm">
<div @vm-oimo-body="handleBody">
<slot></slot>
</div>
</template>
Expand All @@ -10,7 +10,7 @@ export default {
inject: ['spaceVms'],
data () {
return { bodyVm: null }
return { body: null }
},
mounted () {
Expand All @@ -22,15 +22,10 @@ export default {
if (index > -1) this.spaceVms.splice(index, 1)
},
computed: {
body () {
return this.bodyVm && this.bodyVm.body
}
},
methods: {
handleBodyVm (e) {
this.bodyVm = e.detail
handleBody (e) {
e.stopPropagation()
this.body = e.detail
}
}
}
Expand Down

0 comments on commit 608f78d

Please sign in to comment.