@@ -12,7 +12,7 @@ export default {
12
12
props,
13
13
14
14
created ( ) {
15
- const dom = this . _requireWeexModule ( 'dom' )
15
+ const dom = this . $requireWeexModule ( 'dom' )
16
16
this . getPosition = el => new Promise ( ( resolve , reject ) => {
17
17
dom . getComponentRect ( el . ref , res => {
18
18
if ( ! res . result ) {
@@ -23,7 +23,7 @@ export default {
23
23
} )
24
24
} )
25
25
26
- const animation = this . _requireWeexModule ( 'animation' )
26
+ const animation = this . $requireWeexModule ( 'animation' )
27
27
this . animate = ( el , options ) => new Promise ( resolve => {
28
28
animation . transition ( el . ref , options , resolve )
29
29
} )
@@ -57,12 +57,11 @@ export default {
57
57
if ( prevChildren ) {
58
58
const kept = [ ]
59
59
const removed = [ ]
60
- const positionPromises = [ ]
61
60
prevChildren . forEach ( c => {
62
61
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
+
66
65
if ( map [ c . key ] ) {
67
66
kept . push ( c )
68
67
} else {
@@ -71,7 +70,6 @@ export default {
71
70
} )
72
71
this . kept = h ( tag , null , kept )
73
72
this . removed = removed
74
- this . pendingPositions = Promise . all ( positionPromises )
75
73
}
76
74
77
75
return h ( tag , null , children )
@@ -96,39 +94,38 @@ export default {
96
94
return
97
95
}
98
96
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
+ // })
132
129
} ,
133
130
134
131
methods : {
0 commit comments