File tree Expand file tree Collapse file tree 3 files changed +12
-52
lines changed Expand file tree Collapse file tree 3 files changed +12
-52
lines changed Original file line number Diff line number Diff line change 3
3
justify-content : center ;
4
4
align-items : center ;
5
5
overflow : hidden ;
6
+
7
+ &__hide {
8
+ height : 0 !important ;
9
+ display : none ;
10
+ }
11
+
12
+ &__animated&__hide {
13
+ display : flex ;
14
+ }
6
15
}
7
16
8
17
.loading {
Original file line number Diff line number Diff line change @@ -10,17 +10,11 @@ Component({
10
10
show : {
11
11
// 默认显示出来
12
12
type : Boolean ,
13
- value : true ,
14
- observer ( newValue ) {
15
- this . _computedStyle ( newValue , this . data . animated )
16
- }
13
+ value : true
17
14
} ,
18
15
animated : {
19
16
type : Boolean ,
20
- value : false ,
21
- observer ( newValue ) {
22
- this . _computedStyle ( this . data . show , newValue )
23
- }
17
+ value : false
24
18
} ,
25
19
duration : {
26
20
// 过渡动画时间
@@ -36,48 +30,5 @@ Component({
36
30
type : String ,
37
31
value : '加载中'
38
32
}
39
- } ,
40
- data : {
41
- animationData : { } ,
42
- animationInstance : { } ,
43
- displayStyle : 'none'
44
- } ,
45
- methods : {
46
- _computedStyle ( show , animated ) {
47
- if ( ! show ) {
48
- if ( ! animated ) {
49
- this . setData ( {
50
- displayStyle : 'none'
51
- } )
52
- } else {
53
- this . _startAnimation ( )
54
- }
55
- } else {
56
- this . setData ( {
57
- displayStyle : ''
58
- } )
59
- }
60
- } ,
61
- _startAnimation ( ) {
62
- setTimeout ( ( ) => {
63
- const data : any = this . data
64
- const animation = data . animationInstance
65
- animation . height ( 0 ) . step ( )
66
- this . setData ( {
67
- animationData : animation . export ( )
68
- } )
69
- } , 0 )
70
- }
71
- } ,
72
- lifetimes : {
73
- attached ( ) {
74
- const data : any = this . data
75
- const animationInstance = wx . createAnimation ( {
76
- duration : data . duration ,
77
- timingFunction : 'ease'
78
- } )
79
- this . setData ( { animationInstance } )
80
- this . _computedStyle ( this . data . show , this . data . animated )
81
- }
82
33
}
83
34
} )
Original file line number Diff line number Diff line change 1
- <view style="display:{{displayStyle}};" class="wx_loading_view {{extClass}}" animation ="{{animationData }}" id="wx_loading_view">
1
+ <view class="wx_loading_view {{animated ? 'wx_loading_view__animated' : ''}} {{!show ? 'wx_loading_view__hide' : ''}} {{extClass}}" style ="{{animated ? 'transition: height ' + duration + 'ms ease;' : '' }}" id="wx_loading_view">
2
2
<view wx:if="{{type==='dot-white'}}" class="loading wx_dot_loading wx_dot_loading_white">
3
3
</view>
4
4
<view wx:elif="{{type==='dot-gray'}}" class="loading wx_dot_loading"></view>
You can’t perform that action at this time.
0 commit comments