-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
43 lines (42 loc) · 1005 Bytes
/
js.js
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
/**
* Apply JavaScript enter/leave functions.
*
* @param {Element} el
* @param {Number} direction - 1: enter, -1: leave
* @param {Function} op - the actual DOM operation
* @param {Object} data - target element's transition data
* @param {Object} def - transition definition object
* @param {Vue} vm - the owner vm of the element
* @param {Function} [cb]
*/
module.exports = function (el, direction, op, data, def, vm, cb) {
if (data.cancel) {
data.cancel()
data.cancel = null
}
if (direction > 0) { // enter
if (def.beforeEnter) {
def.beforeEnter.call(vm, el)
}
op()
if (def.enter) {
data.cancel = def.enter.call(vm, el, function () {
data.cancel = null
if (cb) cb()
})
} else if (cb) {
cb()
}
} else { // leave
if (def.leave) {
data.cancel = def.leave.call(vm, el, function () {
data.cancel = null
op()
if (cb) cb()
})
} else {
op()
if (cb) cb()
}
}
}