Skip to content

Commit 0906b09

Browse files
wip(oimo): cancelable 'n nextTick
1 parent 01b2576 commit 0906b09

File tree

4 files changed

+14
-13
lines changed

4 files changed

+14
-13
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ Vue.use(VueThreejs)
5454
- [ ] global-control
5555
- [ ] Physical engine
5656
- [x] movement(a/v/pos/ra/rv/rot)/mass(m/F)
57-
- [ ] gravity(G/r)/collision
57+
- [x] gravity(G/r)/collision/oimo
58+
- [ ] circular-motion/centripetal-force
5859
- [ ] Unit test
5960
- [x] karma/mocha/phantom
6061
- [ ] avoriaz/ava

src/components/Base.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export default {
1212
let e = new CustomEvent(name, {
1313
detail,
1414
bubbles: true,
15+
cancelable: true,
1516
...options
1617
})
1718
return this.$el.dispatchEvent(e)

src/oimo/OimoBody.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ export default {
1717
1818
let body = this.world.add(opts)
1919
body.connectMesh(this.curObj)
20-
2120
this.body = body
22-
this.dispatchEvent('vm-oimo-body', this)
21+
22+
// If you want to wait until the entire view has been rendered
23+
// https://vuejs.org/v2/api/#mounted
24+
this.$nextTick(() => {
25+
this.dispatchEvent('vm-oimo-body', body)
26+
})
2327
},
2428
2529
beforeDestroy () {

src/oimo/SpaceObject.vue

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div @vm-oimo-body="handleBodyVm">
2+
<div @vm-oimo-body="handleBody">
33
<slot></slot>
44
</div>
55
</template>
@@ -10,7 +10,7 @@ export default {
1010
inject: ['spaceVms'],
1111
1212
data () {
13-
return { bodyVm: null }
13+
return { body: null }
1414
},
1515
1616
mounted () {
@@ -22,15 +22,10 @@ export default {
2222
if (index > -1) this.spaceVms.splice(index, 1)
2323
},
2424
25-
computed: {
26-
body () {
27-
return this.bodyVm && this.bodyVm.body
28-
}
29-
},
30-
3125
methods: {
32-
handleBodyVm (e) {
33-
this.bodyVm = e.detail
26+
handleBody (e) {
27+
e.stopPropagation()
28+
this.body = e.detail
3429
}
3530
}
3631
}

0 commit comments

Comments
 (0)