Browse code

Remove old version 5

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

Initial commit

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