UNPKG

3.04 kBJavaScriptView Raw
1/**
2 * @license
3 * Copyright 2016 Google Inc.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 * THE SOFTWARE.
22 */
23var 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};
37var 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};
59function isWindow(windowObj) {
60 return Boolean(windowObj.document) && typeof windowObj.document.createElement === 'function';
61}
62export 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}
71export 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//# sourceMappingURL=util.js.map
\No newline at end of file