1
1
import cssAnimation from './css-animation' ;
2
2
import { nextTick } from 'vue' ;
3
+ import { requestAnimationTimeout , cancelAnimationTimeout } from './requestAnimationTimeout' ;
3
4
4
5
function animate ( node , show , done ) {
5
6
let height ;
@@ -8,7 +9,7 @@ function animate(node, show, done) {
8
9
return cssAnimation ( node , 'ant-motion-collapse-legacy' , {
9
10
start ( ) {
10
11
if ( appearRequestAnimationFrameId ) {
11
- cancelAnimationFrame ( appearRequestAnimationFrameId ) ;
12
+ cancelAnimationTimeout ( appearRequestAnimationFrameId ) ;
12
13
}
13
14
if ( ! show ) {
14
15
node . style . height = `${ node . offsetHeight } px` ;
@@ -18,7 +19,7 @@ function animate(node, show, done) {
18
19
// not get offsetHeight when appear
19
20
// set it into raf get correct offsetHeight
20
21
if ( height === 0 ) {
21
- appearRequestAnimationFrameId = requestAnimationFrame ( ( ) => {
22
+ appearRequestAnimationFrameId = requestAnimationTimeout ( ( ) => {
22
23
height = node . offsetHeight ;
23
24
node . style . height = '0px' ;
24
25
node . style . opacity = '0' ;
@@ -31,19 +32,19 @@ function animate(node, show, done) {
31
32
} ,
32
33
active ( ) {
33
34
if ( requestAnimationFrameId ) {
34
- cancelAnimationFrame ( requestAnimationFrameId ) ;
35
+ cancelAnimationTimeout ( requestAnimationFrameId ) ;
35
36
}
36
- requestAnimationFrameId = requestAnimationFrame ( ( ) => {
37
+ requestAnimationFrameId = requestAnimationTimeout ( ( ) => {
37
38
node . style . height = `${ show ? height : 0 } px` ;
38
39
node . style . opacity = show ? '1' : '0' ;
39
40
} ) ;
40
41
} ,
41
42
end ( ) {
42
43
if ( appearRequestAnimationFrameId ) {
43
- cancelAnimationFrame ( appearRequestAnimationFrameId ) ;
44
+ cancelAnimationTimeout ( appearRequestAnimationFrameId ) ;
44
45
}
45
46
if ( requestAnimationFrameId ) {
46
- cancelAnimationFrame ( requestAnimationFrameId ) ;
47
+ cancelAnimationTimeout ( requestAnimationFrameId ) ;
47
48
}
48
49
node . style . height = '' ;
49
50
node . style . opacity = '' ;
0 commit comments