@@ -55,6 +55,11 @@ export default class ParticleEffectButton extends Component {
55
55
progress : 0
56
56
}
57
57
58
+ _rect = {
59
+ width : 0 ,
60
+ height : 0
61
+ }
62
+
58
63
componentWillReceiveProps ( props ) {
59
64
if ( props . hidden !== this . props . hidden ) {
60
65
const { status } = this . state
@@ -88,12 +93,14 @@ export default class ParticleEffectButton extends Component {
88
93
const canvasStyles = { }
89
94
90
95
if ( status === 'hiding' || status === 'showing' ) {
91
- const translateProp = this . _isHorizontal ( ) ? 'translateX' : 'translateY'
92
- const translateValue = direction === 'left' || direction === 'top'
96
+ const prop = this . _isHorizontal ( ) ? 'translateX' : 'translateY'
97
+ const size = this . _isHorizontal ( ) ? this . _rect . width : this . _rect . height
98
+ const value = direction === 'left' || direction === 'top'
93
99
? progress : - progress
100
+ const px = Math . ceil ( size * value / 100 )
94
101
95
- wrapperStyles . transform = `${ translateProp } (${ translateValue } % )`
96
- contentStyles . transform = `${ translateProp } (${ - translateValue } % )`
102
+ wrapperStyles . transform = `${ prop } (${ px } px )`
103
+ contentStyles . transform = `${ prop } (${ - px } px )`
97
104
} else if ( status === 'hidden' ) {
98
105
wrapperStyles . visibility = 'hidden'
99
106
canvasStyles . visibility = 'hidden'
@@ -168,7 +175,6 @@ export default class ParticleEffectButton extends Component {
168
175
begin : onBegin ,
169
176
update : ( anim ) => {
170
177
const value = anim . animatables [ 0 ] . target . value
171
-
172
178
setTimeout ( ( ) => {
173
179
this . setState ( { progress : value } )
174
180
} )
0 commit comments