transition.js
1.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
export var transition = function transition(showDefaultValue) {
return Behavior({
properties: {
customStyle: String,
show: {
type: Boolean,
value: showDefaultValue,
observer: 'observeShow'
},
duration: {
type: Number,
value: 300
}
},
data: {
type: '',
inited: false,
display: false
},
attached: function attached() {
if (this.data.show) {
this.show();
}
},
methods: {
observeShow: function observeShow(value) {
if (value) {
this.show();
} else {
this.setData({
type: 'leave'
});
}
},
show: function show() {
this.setData({
inited: true,
display: true,
type: 'enter'
});
},
onAnimationEnd: function onAnimationEnd() {
if (!this.data.show) {
this.setData({
display: false
});
}
}
}
});
};