transition.js
3.55 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.transition = void 0;
var e = require("../common/utils"), t = function(e) {
return {
enter: "van-" + e + "-enter van-" + e + "-enter-active enter-class enter-active-class",
"enter-to": "van-" + e + "-enter-to van-" + e + "-enter-active enter-to-class enter-active-class",
leave: "van-" + e + "-leave van-" + e + "-leave-active leave-class leave-active-class",
"leave-to": "van-" + e + "-leave-to van-" + e + "-leave-active leave-to-class leave-active-class"
};
}, n = function() {
return new Promise(function(e) {
return setTimeout(e, 1e3 / 30);
});
};
exports.transition = function(a) {
return Behavior({
properties: {
customStyle: String,
show: {
type: Boolean,
value: a,
observer: "observeShow"
},
duration: {
type: null,
value: 300,
observer: "observeDuration"
},
name: {
type: String,
value: "fade"
}
},
data: {
type: "",
inited: !1,
display: !1
},
methods: {
observeShow: function(e, t) {
e !== t && (e ? this.enter() : this.leave());
},
enter: function() {
var a = this, s = this.data, i = s.duration, r = s.name, o = t(r), c = (0, e.isObj)(i) ? i.enter : i;
this.status = "enter", this.$emit("before-enter"), Promise.resolve().then(n).then(function() {
a.checkStatus("enter"), a.$emit("enter"), a.setData({
inited: !0,
display: !0,
classes: o.enter,
currentDuration: c
});
}).then(n).then(function() {
a.checkStatus("enter"), a.transitionEnded = !1, a.setData({
classes: o["enter-to"]
});
}).catch(function() {});
},
leave: function() {
var a = this;
if (this.data.display) {
var s = this.data, i = s.duration, r = s.name, o = t(r), c = (0, e.isObj)(i) ? i.leave : i;
this.status = "leave", this.$emit("before-leave"), Promise.resolve().then(n).then(function() {
a.checkStatus("leave"), a.$emit("leave"), a.setData({
classes: o.leave,
currentDuration: c
});
}).then(n).then(function() {
a.checkStatus("leave"), a.transitionEnded = !1, setTimeout(function() {
return a.onTransitionEnd();
}, c), a.setData({
classes: o["leave-to"]
});
}).catch(function() {});
}
},
checkStatus: function(e) {
if (e !== this.status) throw new Error("incongruent status: " + e);
},
onTransitionEnd: function() {
if (!this.transitionEnded) {
this.transitionEnded = !0, this.$emit("after-" + this.status);
var e = this.data, t = e.show, n = e.display;
!t && n && this.setData({
display: !1
});
}
}
}
});
};