1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,123 +0,0 @@ |
1 |
-import { getWindow } from 'ssr-window'; |
|
2 |
- |
|
3 |
-function deleteProps(obj) { |
|
4 |
- var object = obj; |
|
5 |
- Object.keys(object).forEach(function (key) { |
|
6 |
- try { |
|
7 |
- object[key] = null; |
|
8 |
- } catch (e) {// no getter for object |
|
9 |
- } |
|
10 |
- |
|
11 |
- try { |
|
12 |
- delete object[key]; |
|
13 |
- } catch (e) {// something got wrong |
|
14 |
- } |
|
15 |
- }); |
|
16 |
-} |
|
17 |
- |
|
18 |
-function nextTick(callback, delay) { |
|
19 |
- if (delay === void 0) { |
|
20 |
- delay = 0; |
|
21 |
- } |
|
22 |
- |
|
23 |
- return setTimeout(callback, delay); |
|
24 |
-} |
|
25 |
- |
|
26 |
-function now() { |
|
27 |
- return Date.now(); |
|
28 |
-} |
|
29 |
- |
|
30 |
-function getTranslate(el, axis) { |
|
31 |
- if (axis === void 0) { |
|
32 |
- axis = 'x'; |
|
33 |
- } |
|
34 |
- |
|
35 |
- var window = getWindow(); |
|
36 |
- var matrix; |
|
37 |
- var curTransform; |
|
38 |
- var transformMatrix; |
|
39 |
- var curStyle = window.getComputedStyle(el, null); |
|
40 |
- |
|
41 |
- if (window.WebKitCSSMatrix) { |
|
42 |
- curTransform = curStyle.transform || curStyle.webkitTransform; |
|
43 |
- |
|
44 |
- if (curTransform.split(',').length > 6) { |
|
45 |
- curTransform = curTransform.split(', ').map(function (a) { |
|
46 |
- return a.replace(',', '.'); |
|
47 |
- }).join(', '); |
|
48 |
- } // Some old versions of Webkit choke when 'none' is passed; pass |
|
49 |
- // empty string instead in this case |
|
50 |
- |
|
51 |
- |
|
52 |
- transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); |
|
53 |
- } else { |
|
54 |
- transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); |
|
55 |
- matrix = transformMatrix.toString().split(','); |
|
56 |
- } |
|
57 |
- |
|
58 |
- if (axis === 'x') { |
|
59 |
- // Latest Chrome and webkits Fix |
|
60 |
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix |
|
61 |
- else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers |
|
62 |
- else curTransform = parseFloat(matrix[4]); |
|
63 |
- } |
|
64 |
- |
|
65 |
- if (axis === 'y') { |
|
66 |
- // Latest Chrome and webkits Fix |
|
67 |
- if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix |
|
68 |
- else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers |
|
69 |
- else curTransform = parseFloat(matrix[5]); |
|
70 |
- } |
|
71 |
- |
|
72 |
- return curTransform || 0; |
|
73 |
-} |
|
74 |
- |
|
75 |
-function isObject(o) { |
|
76 |
- return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; |
|
77 |
-} |
|
78 |
- |
|
79 |
-function extend() { |
|
80 |
- var to = Object(arguments.length <= 0 ? undefined : arguments[0]); |
|
81 |
- |
|
82 |
- for (var i = 1; i < arguments.length; i += 1) { |
|
83 |
- var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; |
|
84 |
- |
|
85 |
- if (nextSource !== undefined && nextSource !== null) { |
|
86 |
- var keysArray = Object.keys(Object(nextSource)); |
|
87 |
- |
|
88 |
- for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { |
|
89 |
- var nextKey = keysArray[nextIndex]; |
|
90 |
- var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); |
|
91 |
- |
|
92 |
- if (desc !== undefined && desc.enumerable) { |
|
93 |
- if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
|
94 |
- extend(to[nextKey], nextSource[nextKey]); |
|
95 |
- } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
|
96 |
- to[nextKey] = {}; |
|
97 |
- extend(to[nextKey], nextSource[nextKey]); |
|
98 |
- } else { |
|
99 |
- to[nextKey] = nextSource[nextKey]; |
|
100 |
- } |
|
101 |
- } |
|
102 |
- } |
|
103 |
- } |
|
104 |
- } |
|
105 |
- |
|
106 |
- return to; |
|
107 |
-} |
|
108 |
- |
|
109 |
-function bindModuleMethods(instance, obj) { |
|
110 |
- Object.keys(obj).forEach(function (key) { |
|
111 |
- if (isObject(obj[key])) { |
|
112 |
- Object.keys(obj[key]).forEach(function (subKey) { |
|
113 |
- if (typeof obj[key][subKey] === 'function') { |
|
114 |
- obj[key][subKey] = obj[key][subKey].bind(instance); |
|
115 |
- } |
|
116 |
- }); |
|
117 |
- } |
|
118 |
- |
|
119 |
- instance[key] = obj[key]; |
|
120 |
- }); |
|
121 |
-} |
|
122 |
- |
|
123 |
-export { deleteProps, nextTick, now, getTranslate, isObject, extend, bindModuleMethods }; |
|
124 | 0 |
\ No newline at end of file |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,123 @@ |
1 |
+import { getWindow } from 'ssr-window'; |
|
2 |
+ |
|
3 |
+function deleteProps(obj) { |
|
4 |
+ var object = obj; |
|
5 |
+ Object.keys(object).forEach(function (key) { |
|
6 |
+ try { |
|
7 |
+ object[key] = null; |
|
8 |
+ } catch (e) {// no getter for object |
|
9 |
+ } |
|
10 |
+ |
|
11 |
+ try { |
|
12 |
+ delete object[key]; |
|
13 |
+ } catch (e) {// something got wrong |
|
14 |
+ } |
|
15 |
+ }); |
|
16 |
+} |
|
17 |
+ |
|
18 |
+function nextTick(callback, delay) { |
|
19 |
+ if (delay === void 0) { |
|
20 |
+ delay = 0; |
|
21 |
+ } |
|
22 |
+ |
|
23 |
+ return setTimeout(callback, delay); |
|
24 |
+} |
|
25 |
+ |
|
26 |
+function now() { |
|
27 |
+ return Date.now(); |
|
28 |
+} |
|
29 |
+ |
|
30 |
+function getTranslate(el, axis) { |
|
31 |
+ if (axis === void 0) { |
|
32 |
+ axis = 'x'; |
|
33 |
+ } |
|
34 |
+ |
|
35 |
+ var window = getWindow(); |
|
36 |
+ var matrix; |
|
37 |
+ var curTransform; |
|
38 |
+ var transformMatrix; |
|
39 |
+ var curStyle = window.getComputedStyle(el, null); |
|
40 |
+ |
|
41 |
+ if (window.WebKitCSSMatrix) { |
|
42 |
+ curTransform = curStyle.transform || curStyle.webkitTransform; |
|
43 |
+ |
|
44 |
+ if (curTransform.split(',').length > 6) { |
|
45 |
+ curTransform = curTransform.split(', ').map(function (a) { |
|
46 |
+ return a.replace(',', '.'); |
|
47 |
+ }).join(', '); |
|
48 |
+ } // Some old versions of Webkit choke when 'none' is passed; pass |
|
49 |
+ // empty string instead in this case |
|
50 |
+ |
|
51 |
+ |
|
52 |
+ transformMatrix = new window.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform); |
|
53 |
+ } else { |
|
54 |
+ transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,'); |
|
55 |
+ matrix = transformMatrix.toString().split(','); |
|
56 |
+ } |
|
57 |
+ |
|
58 |
+ if (axis === 'x') { |
|
59 |
+ // Latest Chrome and webkits Fix |
|
60 |
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m41; // Crazy IE10 Matrix |
|
61 |
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[12]); // Normal Browsers |
|
62 |
+ else curTransform = parseFloat(matrix[4]); |
|
63 |
+ } |
|
64 |
+ |
|
65 |
+ if (axis === 'y') { |
|
66 |
+ // Latest Chrome and webkits Fix |
|
67 |
+ if (window.WebKitCSSMatrix) curTransform = transformMatrix.m42; // Crazy IE10 Matrix |
|
68 |
+ else if (matrix.length === 16) curTransform = parseFloat(matrix[13]); // Normal Browsers |
|
69 |
+ else curTransform = parseFloat(matrix[5]); |
|
70 |
+ } |
|
71 |
+ |
|
72 |
+ return curTransform || 0; |
|
73 |
+} |
|
74 |
+ |
|
75 |
+function isObject(o) { |
|
76 |
+ return typeof o === 'object' && o !== null && o.constructor && o.constructor === Object; |
|
77 |
+} |
|
78 |
+ |
|
79 |
+function extend() { |
|
80 |
+ var to = Object(arguments.length <= 0 ? undefined : arguments[0]); |
|
81 |
+ |
|
82 |
+ for (var i = 1; i < arguments.length; i += 1) { |
|
83 |
+ var nextSource = i < 0 || arguments.length <= i ? undefined : arguments[i]; |
|
84 |
+ |
|
85 |
+ if (nextSource !== undefined && nextSource !== null) { |
|
86 |
+ var keysArray = Object.keys(Object(nextSource)); |
|
87 |
+ |
|
88 |
+ for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex += 1) { |
|
89 |
+ var nextKey = keysArray[nextIndex]; |
|
90 |
+ var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); |
|
91 |
+ |
|
92 |
+ if (desc !== undefined && desc.enumerable) { |
|
93 |
+ if (isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
|
94 |
+ extend(to[nextKey], nextSource[nextKey]); |
|
95 |
+ } else if (!isObject(to[nextKey]) && isObject(nextSource[nextKey])) { |
|
96 |
+ to[nextKey] = {}; |
|
97 |
+ extend(to[nextKey], nextSource[nextKey]); |
|
98 |
+ } else { |
|
99 |
+ to[nextKey] = nextSource[nextKey]; |
|
100 |
+ } |
|
101 |
+ } |
|
102 |
+ } |
|
103 |
+ } |
|
104 |
+ } |
|
105 |
+ |
|
106 |
+ return to; |
|
107 |
+} |
|
108 |
+ |
|
109 |
+function bindModuleMethods(instance, obj) { |
|
110 |
+ Object.keys(obj).forEach(function (key) { |
|
111 |
+ if (isObject(obj[key])) { |
|
112 |
+ Object.keys(obj[key]).forEach(function (subKey) { |
|
113 |
+ if (typeof obj[key][subKey] === 'function') { |
|
114 |
+ obj[key][subKey] = obj[key][subKey].bind(instance); |
|
115 |
+ } |
|
116 |
+ }); |
|
117 |
+ } |
|
118 |
+ |
|
119 |
+ instance[key] = obj[key]; |
|
120 |
+ }); |
|
121 |
+} |
|
122 |
+ |
|
123 |
+export { deleteProps, nextTick, now, getTranslate, isObject, extend, bindModuleMethods }; |
|
0 | 124 |
\ No newline at end of file |