-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathenv.js
74 lines (64 loc) · 1.45 KB
/
env.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
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
/**
* Can we use __proto__?
*
* @type {Boolean}
*/
exports.hasProto = '__proto__' in {}
/**
* Indicates we have a window
*
* @type {Boolean}
*/
var toString = Object.prototype.toString
var inBrowser = exports.inBrowser =
typeof window !== 'undefined' &&
toString.call(window) !== '[object Object]'
/**
* Defer a task to the start of the next event loop
*
* @param {Function} cb
* @param {Object} ctx
*/
var defer = inBrowser
? (window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
setTimeout)
: setTimeout
exports.nextTick = function (cb, ctx) {
if (ctx) {
defer(function () { cb.call(ctx) }, 0)
} else {
defer(cb, 0)
}
}
/**
* Detect if we are in IE9...
*
* @type {Boolean}
*/
exports.isIE9 =
inBrowser &&
navigator.userAgent.indexOf('MSIE 9.0') > 0
/**
* Sniff transition/animation events
*/
if (inBrowser && !exports.isIE9) {
var isWebkitTrans =
window.ontransitionend === undefined &&
window.onwebkittransitionend !== undefined
var isWebkitAnim =
window.onanimationend === undefined &&
window.onwebkitanimationend !== undefined
exports.transitionProp = isWebkitTrans
? 'WebkitTransition'
: 'transition'
exports.transitionEndEvent = isWebkitTrans
? 'webkitTransitionEnd'
: 'transitionend'
exports.animationProp = isWebkitAnim
? 'WebkitAnimation'
: 'animation'
exports.animationEndEvent = isWebkitAnim
? 'webkitAnimationEnd'
: 'animationend'
}