-
Notifications
You must be signed in to change notification settings - Fork 0
/
paperCapabilities.js
106 lines (88 loc) · 2.31 KB
/
paperCapabilities.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
window.paper = window.paper || (window.paper = {});
(function(scope) {
var b = document.body || document.documentElement,
style = b.style,
property,
prefix;
// Test for CSS transforms
var transform = false;
var transforms = {
'transform' : '',
'-webkit-transform' : '-webkit-',
'-moz-transform' : '-moz-',
'-ms-transform' : '-ms-',
'-o-transform' : '-o-'
}
for (property in transforms){
if (typeof style[property] === 'string') {
transform = property;
prefix = style[property];
break;
}
}
// Test for CSS transitions
var transition = false;
var transitions = {
'transition' : '',
'-webkit-transition' : '-webkit-',
'-moz-transition' : '-moz-',
'-ms-transition' : '-ms-',
'-o-transition' : '-o-'
}
for (property in transitions){
if (typeof style[property] === 'string') {
transition = property;
break;
}
}
// Test for CSS Transition Event
var transitionEnd = false;
if ('ontransitionend' in window) {
transitionEnd = 'transitionend';
} else if ('onwebkittransitionend' in window) {
transitionEnd = 'webkitTransitionEnd';
} else {
if (transition) {
if (prefix === '') {
transitionEnd = 'transitionend';
} else if (prefix === '-moz-') {
transitionEnd = 'transitionend';
} else if (prefix === '-o-') {
transitionEnd = 'oTransitionEnd';
}
}
}
// transition = '-webkit-transition'
// prefix = '-webkit-'
// Test for 3d transforms
var transform3d = false;
if ('perspective' in style || '-webkit-perspective' in style || '-moz-perspective' in style) {
transform3d = true;
}
// Test for Native Animations
var nativeAnimations = false;
if (typeof b.animate === 'function') {
nativeAnimations = true;
}
// Detect old browsers: IE8
var oldBrowser = false;
if (typeof document.createElement('SVG').getAttributeNS === 'undefined') {
oldBrowser = true;
}
// Detect touch support
var hasTouch = false;
if ('ontouchstart' in window || navigator.msMaxTouchPoints) {
hasTouch = true;
}
scope.capabilities = {
transition : transition,
transitionEnd : transitionEnd,
transform : transform,
transform3d : transform3d,
prefix : prefix,
nativeAnimations : nativeAnimations,
oldBrowser : oldBrowser,
hasTouch : hasTouch
}
// alert( JSON.stringify(scope.capabilities))
}(paper))