1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | var cssPropertyNameMap = {
|
24 | animation: {
|
25 | prefixed: '-webkit-animation',
|
26 | standard: 'animation',
|
27 | },
|
28 | transform: {
|
29 | prefixed: '-webkit-transform',
|
30 | standard: 'transform',
|
31 | },
|
32 | transition: {
|
33 | prefixed: '-webkit-transition',
|
34 | standard: 'transition',
|
35 | },
|
36 | };
|
37 | var jsEventTypeMap = {
|
38 | animationend: {
|
39 | cssProperty: 'animation',
|
40 | prefixed: 'webkitAnimationEnd',
|
41 | standard: 'animationend',
|
42 | },
|
43 | animationiteration: {
|
44 | cssProperty: 'animation',
|
45 | prefixed: 'webkitAnimationIteration',
|
46 | standard: 'animationiteration',
|
47 | },
|
48 | animationstart: {
|
49 | cssProperty: 'animation',
|
50 | prefixed: 'webkitAnimationStart',
|
51 | standard: 'animationstart',
|
52 | },
|
53 | transitionend: {
|
54 | cssProperty: 'transition',
|
55 | prefixed: 'webkitTransitionEnd',
|
56 | standard: 'transitionend',
|
57 | },
|
58 | };
|
59 | function isWindow(windowObj) {
|
60 | return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
|
61 | }
|
62 | export function getCorrectPropertyName(windowObj, cssProperty) {
|
63 | if (isWindow(windowObj) && cssProperty in cssPropertyNameMap) {
|
64 | var el = windowObj.document.createElement('div');
|
65 | var _a = cssPropertyNameMap[cssProperty], standard = _a.standard, prefixed = _a.prefixed;
|
66 | var isStandard = standard in el.style;
|
67 | return isStandard ? standard : prefixed;
|
68 | }
|
69 | return cssProperty;
|
70 | }
|
71 | export function getCorrectEventName(windowObj, eventType) {
|
72 | if (isWindow(windowObj) && eventType in jsEventTypeMap) {
|
73 | var el = windowObj.document.createElement('div');
|
74 | var _a = jsEventTypeMap[eventType], standard = _a.standard, prefixed = _a.prefixed, cssProperty = _a.cssProperty;
|
75 | var isStandard = cssProperty in el.style;
|
76 | return isStandard ? standard : prefixed;
|
77 | }
|
78 | return eventType;
|
79 | }
|
80 |
|
\ | No newline at end of file |