Skip to content

Commit 92fb118

Browse files
committed
[weex] disable transition-group move animation for now
1 parent d99637b commit 92fb118

File tree

1 file changed

+37
-40
lines changed

1 file changed

+37
-40
lines changed

src/platforms/weex/runtime/components/transition-group.js

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export default {
1212
props,
1313

1414
created () {
15-
const dom = this._requireWeexModule('dom')
15+
const dom = this.$requireWeexModule('dom')
1616
this.getPosition = el => new Promise((resolve, reject) => {
1717
dom.getComponentRect(el.ref, res => {
1818
if (!res.result) {
@@ -23,7 +23,7 @@ export default {
2323
})
2424
})
2525

26-
const animation = this._requireWeexModule('animation')
26+
const animation = this.$requireWeexModule('animation')
2727
this.animate = (el, options) => new Promise(resolve => {
2828
animation.transition(el.ref, options, resolve)
2929
})
@@ -57,12 +57,11 @@ export default {
5757
if (prevChildren) {
5858
const kept = []
5959
const removed = []
60-
const positionPromises = []
6160
prevChildren.forEach(c => {
6261
c.data.transition = transitionData
63-
positionPromises.push(this.getPosition(c.elm).then(pos => {
64-
c.data.pos = pos
65-
}))
62+
63+
// TODO: record before patch positions
64+
6665
if (map[c.key]) {
6766
kept.push(c)
6867
} else {
@@ -71,7 +70,6 @@ export default {
7170
})
7271
this.kept = h(tag, null, kept)
7372
this.removed = removed
74-
this.pendingPositions = Promise.all(positionPromises)
7573
}
7674

7775
return h(tag, null, children)
@@ -96,39 +94,38 @@ export default {
9694
return
9795
}
9896

99-
children.forEach(callPendingCbs)
100-
this.pendingPositions.then(() => Promise.all(children.map(c => {
101-
// record new position
102-
return this.getPosition(c.elm).then(pos => {
103-
c.data.newPos = pos
104-
})
105-
}))).then(() => Promise.all(children.map(c => {
106-
const oldPos = c.data.pos
107-
const newPos = c.data.newPos
108-
const dx = oldPos.left - newPos.left
109-
const dy = oldPos.top - newPos.top
110-
if (dx || dy) {
111-
c.data.moved = true
112-
return this.animate(c.elm, {
113-
styles: {
114-
transform: `translate(${dx}px,${dy}px)`
115-
}
116-
})
117-
}
118-
}))).then(() => {
119-
children.forEach(c => {
120-
if (c.data.moved) {
121-
this.animate(c.elm, {
122-
styles: {
123-
transform: ''
124-
},
125-
duration: moveData.duration || 0,
126-
delay: moveData.delay || 0,
127-
timingFunction: moveData.timingFunction || 'linear'
128-
})
129-
}
130-
})
131-
})
97+
// TODO: finish implementing move animations once
98+
// we have access to sync getComponentRect()
99+
100+
// children.forEach(callPendingCbs)
101+
102+
// Promise.all(children.map(c => {
103+
// const oldPos = c.data.pos
104+
// const newPos = c.data.newPos
105+
// const dx = oldPos.left - newPos.left
106+
// const dy = oldPos.top - newPos.top
107+
// if (dx || dy) {
108+
// c.data.moved = true
109+
// return this.animate(c.elm, {
110+
// styles: {
111+
// transform: `translate(${dx}px,${dy}px)`
112+
// }
113+
// })
114+
// }
115+
// })).then(() => {
116+
// children.forEach(c => {
117+
// if (c.data.moved) {
118+
// this.animate(c.elm, {
119+
// styles: {
120+
// transform: ''
121+
// },
122+
// duration: moveData.duration || 0,
123+
// delay: moveData.delay || 0,
124+
// timingFunction: moveData.timingFunction || 'linear'
125+
// })
126+
// }
127+
// })
128+
// })
132129
},
133130

134131
methods: {

0 commit comments

Comments
 (0)