@studiometa/js-toolkit 1.7.2 → 2.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. package/Base/index.d.ts +217 -0
  2. package/Base/index.js +237 -0
  3. package/Base/managers/ChildrenManager.d.ts +108 -0
  4. package/Base/managers/ChildrenManager.js +124 -0
  5. package/Base/managers/EventsManager.d.ts +190 -0
  6. package/Base/managers/EventsManager.js +195 -0
  7. package/Base/managers/OptionsManager.d.ts +120 -0
  8. package/Base/managers/OptionsManager.js +180 -0
  9. package/Base/managers/RefsManager.d.ts +84 -0
  10. package/Base/managers/RefsManager.js +83 -0
  11. package/{abstracts/Base/classes/Services.d.ts → Base/managers/ServicesManager.d.ts} +22 -7
  12. package/Base/managers/ServicesManager.js +115 -0
  13. package/{abstracts/Base → Base}/utils.d.ts +0 -30
  14. package/Base/utils.js +43 -0
  15. package/README.md +12 -70
  16. package/decorators/index.js +1 -2
  17. package/decorators/withBreakpointManager.d.ts +5 -5
  18. package/decorators/withBreakpointManager.js +41 -79
  19. package/decorators/withBreakpointObserver.d.ts +4 -4
  20. package/decorators/withBreakpointObserver.js +54 -77
  21. package/decorators/withDrag.d.ts +6 -6
  22. package/decorators/withDrag.js +17 -41
  23. package/decorators/withExtraConfig.d.ts +6 -6
  24. package/decorators/withExtraConfig.js +2 -24
  25. package/decorators/withIntersectionObserver.d.ts +4 -4
  26. package/decorators/withIntersectionObserver.js +17 -60
  27. package/decorators/withMountWhenInView.d.ts +8 -8
  28. package/decorators/withMountWhenInView.js +23 -51
  29. package/helpers/createApp.d.ts +4 -4
  30. package/helpers/createApp.js +10 -12
  31. package/helpers/importOnInteraction.d.ts +6 -6
  32. package/helpers/importOnInteraction.js +7 -8
  33. package/helpers/importWhenIdle.d.ts +4 -4
  34. package/helpers/importWhenIdle.js +7 -8
  35. package/helpers/importWhenVisible.d.ts +6 -6
  36. package/helpers/importWhenVisible.js +9 -16
  37. package/helpers/index.d.ts +1 -3
  38. package/helpers/index.js +1 -4
  39. package/helpers/utils.js +2 -3
  40. package/index.d.ts +19 -5
  41. package/index.js +5 -6
  42. package/index.modern.js +1 -3230
  43. package/index.umd.js +1 -3586
  44. package/package.json +3 -6
  45. package/{abstracts → services}/Service.d.ts +0 -0
  46. package/services/Service.js +63 -0
  47. package/services/drag.js +144 -180
  48. package/services/index.js +1 -2
  49. package/services/key.js +56 -98
  50. package/services/load.d.ts +1 -1
  51. package/services/load.js +22 -51
  52. package/services/pointer.js +118 -157
  53. package/services/raf.js +37 -65
  54. package/services/resize.js +46 -98
  55. package/services/scroll.js +81 -120
  56. package/utils/collide/boundingRectToCircle.js +7 -6
  57. package/utils/collide/collideCircleCircle.js +1 -2
  58. package/utils/collide/collideCircleRect.js +1 -2
  59. package/utils/collide/collidePointCircle.js +1 -2
  60. package/utils/collide/collidePointRect.js +1 -2
  61. package/utils/collide/collideRectRect.js +1 -2
  62. package/utils/collide/index.js +1 -2
  63. package/utils/css/classes.js +2 -3
  64. package/utils/css/index.js +1 -2
  65. package/utils/css/matrix.js +1 -2
  66. package/utils/css/styles.js +3 -8
  67. package/utils/css/transition.js +67 -140
  68. package/utils/debounce.js +3 -4
  69. package/utils/focusTrap.js +4 -5
  70. package/utils/history.js +12 -19
  71. package/utils/index.d.ts +2 -1
  72. package/utils/index.js +2 -2
  73. package/utils/keyCodes.js +1 -2
  74. package/utils/math/clamp.js +1 -2
  75. package/utils/math/clamp01.js +1 -2
  76. package/utils/math/damp.js +1 -2
  77. package/utils/math/index.js +1 -2
  78. package/utils/math/inertiaFinalValue.js +1 -2
  79. package/utils/math/lerp.js +1 -2
  80. package/utils/math/map.js +1 -2
  81. package/utils/math/round.js +1 -2
  82. package/utils/memoize.d.ts +30 -0
  83. package/utils/memoize.js +30 -0
  84. package/utils/nextFrame.js +4 -9
  85. package/utils/object/autoBind.js +11 -19
  86. package/utils/object/getAllProperties.d.ts +6 -3
  87. package/utils/object/getAllProperties.js +10 -8
  88. package/utils/object/index.js +1 -2
  89. package/utils/object/isObject.js +2 -4
  90. package/utils/string/index.js +1 -2
  91. package/utils/string/withLeadingCharacters.js +1 -2
  92. package/utils/string/withLeadingSlash.js +1 -2
  93. package/utils/string/withTrailingCharacters.js +1 -2
  94. package/utils/string/withTrailingSlash.js +1 -2
  95. package/utils/string/withoutLeadingCharacters.js +1 -2
  96. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  97. package/utils/string/withoutLeadingSlash.js +1 -2
  98. package/utils/string/withoutTrailingCharacters.js +1 -2
  99. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  100. package/utils/string/withoutTrailingSlash.js +1 -2
  101. package/utils/throttle.js +2 -3
  102. package/abstracts/Base/children.d.ts +0 -16
  103. package/abstracts/Base/children.js +0 -66
  104. package/abstracts/Base/children.js.map +0 -1
  105. package/abstracts/Base/classes/Options.d.ts +0 -37
  106. package/abstracts/Base/classes/Options.js +0 -182
  107. package/abstracts/Base/classes/Options.js.map +0 -1
  108. package/abstracts/Base/classes/Services.js +0 -120
  109. package/abstracts/Base/classes/Services.js.map +0 -1
  110. package/abstracts/Base/components.d.ts +0 -22
  111. package/abstracts/Base/components.js +0 -67
  112. package/abstracts/Base/components.js.map +0 -1
  113. package/abstracts/Base/events.d.ts +0 -8
  114. package/abstracts/Base/events.js +0 -185
  115. package/abstracts/Base/events.js.map +0 -1
  116. package/abstracts/Base/index.d.ts +0 -176
  117. package/abstracts/Base/index.js +0 -215
  118. package/abstracts/Base/index.js.map +0 -1
  119. package/abstracts/Base/options.d.ts +0 -17
  120. package/abstracts/Base/options.js +0 -112
  121. package/abstracts/Base/options.js.map +0 -1
  122. package/abstracts/Base/refs.d.ts +0 -30
  123. package/abstracts/Base/refs.js +0 -60
  124. package/abstracts/Base/refs.js.map +0 -1
  125. package/abstracts/Base/utils.js +0 -102
  126. package/abstracts/Base/utils.js.map +0 -1
  127. package/abstracts/EventManager.d.ts +0 -41
  128. package/abstracts/EventManager.js +0 -88
  129. package/abstracts/EventManager.js.map +0 -1
  130. package/abstracts/Service.js +0 -82
  131. package/abstracts/Service.js.map +0 -1
  132. package/abstracts/index.d.ts +0 -4
  133. package/abstracts/index.js +0 -5
  134. package/abstracts/index.js.map +0 -1
  135. package/components/Accordion/Accordion.d.ts +0 -83
  136. package/components/Accordion/Accordion.js +0 -121
  137. package/components/Accordion/Accordion.js.map +0 -1
  138. package/components/Accordion/AccordionItem.d.ts +0 -122
  139. package/components/Accordion/AccordionItem.js +0 -327
  140. package/components/Accordion/AccordionItem.js.map +0 -1
  141. package/components/Accordion/index.d.ts +0 -27
  142. package/components/Accordion/index.js +0 -39
  143. package/components/Accordion/index.js.map +0 -1
  144. package/components/Cursor.d.ts +0 -138
  145. package/components/Cursor.js +0 -167
  146. package/components/Cursor.js.map +0 -1
  147. package/components/Draggable.d.ts +0 -49
  148. package/components/Draggable.js +0 -77
  149. package/components/Draggable.js.map +0 -1
  150. package/components/Modal.d.ts +0 -158
  151. package/components/Modal.js +0 -270
  152. package/components/Modal.js.map +0 -1
  153. package/components/Tabs.d.ts +0 -108
  154. package/components/Tabs.js +0 -195
  155. package/components/Tabs.js.map +0 -1
  156. package/components/index.d.ts +0 -6
  157. package/components/index.js +0 -7
  158. package/components/index.js.map +0 -1
  159. package/decorators/index.js.map +0 -1
  160. package/decorators/withBreakpointManager.js.map +0 -1
  161. package/decorators/withBreakpointObserver.js.map +0 -1
  162. package/decorators/withDrag.js.map +0 -1
  163. package/decorators/withExtraConfig.js.map +0 -1
  164. package/decorators/withIntersectionObserver.js.map +0 -1
  165. package/decorators/withMountWhenInView.js.map +0 -1
  166. package/full.d.ts +0 -10
  167. package/full.js +0 -12
  168. package/full.js.map +0 -1
  169. package/full.modern.js +0 -7523
  170. package/full.modern.js.map +0 -1
  171. package/full.umd.js +0 -8277
  172. package/full.umd.js.map +0 -1
  173. package/helpers/createApp.js.map +0 -1
  174. package/helpers/createBase.d.ts +0 -7
  175. package/helpers/createBase.js +0 -7
  176. package/helpers/createBase.js.map +0 -1
  177. package/helpers/defineComponent.d.ts +0 -11
  178. package/helpers/defineComponent.js +0 -68
  179. package/helpers/defineComponent.js.map +0 -1
  180. package/helpers/importOnInteraction.js.map +0 -1
  181. package/helpers/importWhenIdle.js.map +0 -1
  182. package/helpers/importWhenVisible.js.map +0 -1
  183. package/helpers/index.js.map +0 -1
  184. package/helpers/utils.js.map +0 -1
  185. package/index.js.map +0 -1
  186. package/index.modern.js.map +0 -1
  187. package/index.umd.js.map +0 -1
  188. package/services/drag.js.map +0 -1
  189. package/services/index.js.map +0 -1
  190. package/services/key.js.map +0 -1
  191. package/services/load.js.map +0 -1
  192. package/services/pointer.js.map +0 -1
  193. package/services/raf.js.map +0 -1
  194. package/services/resize.js.map +0 -1
  195. package/services/scroll.js.map +0 -1
  196. package/utils/collide/boundingRectToCircle.js.map +0 -1
  197. package/utils/collide/collideCircleCircle.js.map +0 -1
  198. package/utils/collide/collideCircleRect.js.map +0 -1
  199. package/utils/collide/collidePointCircle.js.map +0 -1
  200. package/utils/collide/collidePointRect.js.map +0 -1
  201. package/utils/collide/collideRectRect.js.map +0 -1
  202. package/utils/collide/index.js.map +0 -1
  203. package/utils/css/classes.js.map +0 -1
  204. package/utils/css/index.js.map +0 -1
  205. package/utils/css/matrix.js.map +0 -1
  206. package/utils/css/styles.js.map +0 -1
  207. package/utils/css/transition.js.map +0 -1
  208. package/utils/debounce.js.map +0 -1
  209. package/utils/focusTrap.js.map +0 -1
  210. package/utils/history.js.map +0 -1
  211. package/utils/index.js.map +0 -1
  212. package/utils/keyCodes.js.map +0 -1
  213. package/utils/math/clamp.js.map +0 -1
  214. package/utils/math/clamp01.js.map +0 -1
  215. package/utils/math/damp.js.map +0 -1
  216. package/utils/math/index.js.map +0 -1
  217. package/utils/math/inertiaFinalValue.js.map +0 -1
  218. package/utils/math/lerp.js.map +0 -1
  219. package/utils/math/map.js.map +0 -1
  220. package/utils/math/round.js.map +0 -1
  221. package/utils/nextFrame.js.map +0 -1
  222. package/utils/object/autoBind.js.map +0 -1
  223. package/utils/object/getAllProperties.js.map +0 -1
  224. package/utils/object/index.js.map +0 -1
  225. package/utils/object/isObject.js.map +0 -1
  226. package/utils/string/index.js.map +0 -1
  227. package/utils/string/withLeadingCharacters.js.map +0 -1
  228. package/utils/string/withLeadingSlash.js.map +0 -1
  229. package/utils/string/withTrailingCharacters.js.map +0 -1
  230. package/utils/string/withTrailingSlash.js.map +0 -1
  231. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  232. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  233. package/utils/string/withoutLeadingSlash.js.map +0 -1
  234. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  235. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  236. package/utils/string/withoutTrailingSlash.js.map +0 -1
  237. package/utils/throttle.js.map +0 -1
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @return {ServiceInterface & LoadService}
13
13
  */
14
- export default function useRaf(): ServiceInterface & LoadService;
14
+ export default function useLoad(): ServiceInterface & LoadService;
15
15
  export type ServiceInterface = import('./index').ServiceInterface;
16
16
  export type LoadServiceProps = {
17
17
  time: DOMHighResTimeStamp;
package/services/load.js CHANGED
@@ -1,56 +1,28 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _inherits from "@babel/runtime/helpers/inherits";
4
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
1
+ import Service from './Service.js';
6
2
 
7
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
3
+ class Load extends Service {
4
+ init() {
5
+ this.handler = () => {
6
+ this.trigger(this.props);
7
+ };
8
8
 
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
-
11
- import Service from '../abstracts/Service.js';
12
-
13
- var Load = function (_Service) {
14
- _inherits(Load, _Service);
15
-
16
- var _super = _createSuper(Load);
17
-
18
- function Load() {
19
- _classCallCheck(this, Load);
20
-
21
- return _super.apply(this, arguments);
9
+ window.addEventListener('load', this.handler);
10
+ return this;
22
11
  }
23
12
 
24
- _createClass(Load, [{
25
- key: "init",
26
- value: function init() {
27
- var _this = this;
28
-
29
- this.handler = function () {
30
- _this.trigger(_this.props);
31
- };
13
+ kill() {
14
+ window.removeEventListener('load', this.handler);
15
+ return this;
16
+ }
32
17
 
33
- window.addEventListener('load', this.handler);
34
- return this;
35
- }
36
- }, {
37
- key: "kill",
38
- value: function kill() {
39
- window.removeEventListener('load', this.handler);
40
- return this;
41
- }
42
- }, {
43
- key: "props",
44
- get: function get() {
45
- return {};
46
- }
47
- }]);
18
+ get props() {
19
+ return {};
20
+ }
48
21
 
49
- return Load;
50
- }(Service);
22
+ }
51
23
 
52
24
  var instance = null;
53
- export default function useRaf() {
25
+ export default function useLoad() {
54
26
  if (!instance) {
55
27
  instance = new Load();
56
28
  }
@@ -64,10 +36,9 @@ export default function useRaf() {
64
36
  }
65
37
 
66
38
  return {
67
- add: add,
68
- remove: remove,
69
- has: has,
70
- props: props
39
+ add,
40
+ remove,
41
+ has,
42
+ props
71
43
  };
72
- }
73
- //# sourceMappingURL=load.js.map
44
+ }
@@ -1,177 +1,141 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import Service from '../abstracts/Service.js';
2
+ import Service from './Service.js';
14
3
 
15
4
  function isTouchEvent(event) {
16
5
  return typeof TouchEvent !== 'undefined' && event instanceof TouchEvent;
17
6
  }
18
7
 
19
- var Pointer = function (_Service) {
20
- _inherits(Pointer, _Service);
8
+ class Pointer extends Service {
9
+ constructor() {
10
+ super(...arguments);
21
11
 
22
- var _super = _createSuper(Pointer);
12
+ _defineProperty(this, "isDown", false);
23
13
 
24
- function Pointer() {
25
- var _this;
14
+ _defineProperty(this, "y", window.innerHeight / 2);
26
15
 
27
- _classCallCheck(this, Pointer);
16
+ _defineProperty(this, "yLast", window.innerHeight / 2);
28
17
 
29
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
- args[_key] = arguments[_key];
31
- }
18
+ _defineProperty(this, "x", window.innerWidth / 2);
32
19
 
33
- _this = _super.call.apply(_super, [this].concat(args));
20
+ _defineProperty(this, "xLast", window.innerWidth / 2);
34
21
 
35
- _defineProperty(_assertThisInitialized(_this), "isDown", false);
22
+ _defineProperty(this, "event", void 0);
36
23
 
37
- _defineProperty(_assertThisInitialized(_this), "y", window.innerHeight / 2);
24
+ _defineProperty(this, "hasRaf", false);
25
+ }
38
26
 
39
- _defineProperty(_assertThisInitialized(_this), "yLast", window.innerHeight / 2);
27
+ init() {
28
+ document.documentElement.addEventListener('mouseenter', this, {
29
+ once: true,
30
+ capture: true
31
+ });
32
+ var options = {
33
+ passive: true,
34
+ capture: true
35
+ };
36
+ document.addEventListener('mousemove', this, options);
37
+ document.addEventListener('touchmove', this, options);
38
+ document.addEventListener('mousedown', this, options);
39
+ document.addEventListener('touchstart', this, options);
40
+ document.addEventListener('mouseup', this, options);
41
+ document.addEventListener('touchend', this, options);
42
+ return this;
43
+ }
40
44
 
41
- _defineProperty(_assertThisInitialized(_this), "x", window.innerWidth / 2);
45
+ handleEvent(event) {
46
+ switch (event.type) {
47
+ case 'mouseenter':
48
+ case 'mousemove':
49
+ case 'touchmove':
50
+ this.handler(event);
51
+ break;
52
+
53
+ case 'mousedown':
54
+ case 'touchstart':
55
+ this.downHandler();
56
+ break;
57
+
58
+ case 'mouseup':
59
+ case 'touchend':
60
+ this.upHandler();
61
+ break;
62
+ }
63
+ }
42
64
 
43
- _defineProperty(_assertThisInitialized(_this), "xLast", window.innerWidth / 2);
65
+ kill() {
66
+ document.removeEventListener('mousemove', this);
67
+ document.removeEventListener('touchmove', this);
68
+ document.removeEventListener('mousedown', this);
69
+ document.removeEventListener('touchstart', this);
70
+ document.removeEventListener('mouseup', this);
71
+ document.removeEventListener('touchend', this);
72
+ return this;
73
+ }
44
74
 
45
- _defineProperty(_assertThisInitialized(_this), "event", void 0);
75
+ handler(event) {
76
+ this.updateValues(event);
77
+ this.trigger(this.props);
78
+ }
46
79
 
47
- _defineProperty(_assertThisInitialized(_this), "hasRaf", false);
80
+ downHandler() {
81
+ this.isDown = true;
82
+ this.trigger(this.props);
83
+ }
48
84
 
49
- return _this;
85
+ upHandler() {
86
+ this.isDown = false;
87
+ this.trigger(this.props);
50
88
  }
51
89
 
52
- _createClass(Pointer, [{
53
- key: "init",
54
- value: function init() {
55
- document.documentElement.addEventListener('mouseenter', this, {
56
- once: true,
57
- capture: true
58
- });
59
- var options = {
60
- passive: true,
61
- capture: true
62
- };
63
- document.addEventListener('mousemove', this, options);
64
- document.addEventListener('touchmove', this, options);
65
- document.addEventListener('mousedown', this, options);
66
- document.addEventListener('touchstart', this, options);
67
- document.addEventListener('mouseup', this, options);
68
- document.addEventListener('touchend', this, options);
69
- return this;
70
- }
71
- }, {
72
- key: "handleEvent",
73
- value: function handleEvent(event) {
74
- switch (event.type) {
75
- case 'mouseenter':
76
- case 'mousemove':
77
- case 'touchmove':
78
- this.handler(event);
79
- break;
80
-
81
- case 'mousedown':
82
- case 'touchstart':
83
- this.downHandler();
84
- break;
85
-
86
- case 'mouseup':
87
- case 'touchend':
88
- this.upHandler();
89
- break;
90
- }
91
- }
92
- }, {
93
- key: "kill",
94
- value: function kill() {
95
- document.removeEventListener('mousemove', this);
96
- document.removeEventListener('touchmove', this);
97
- document.removeEventListener('mousedown', this);
98
- document.removeEventListener('touchstart', this);
99
- document.removeEventListener('mouseup', this);
100
- document.removeEventListener('touchend', this);
101
- return this;
102
- }
103
- }, {
104
- key: "handler",
105
- value: function handler(event) {
106
- this.updateValues(event);
107
- this.trigger(this.props);
108
- }
109
- }, {
110
- key: "downHandler",
111
- value: function downHandler() {
112
- this.isDown = true;
113
- this.trigger(this.props);
114
- }
115
- }, {
116
- key: "upHandler",
117
- value: function upHandler() {
118
- this.isDown = false;
119
- this.trigger(this.props);
120
- }
121
- }, {
122
- key: "updateValues",
123
- value: function updateValues(event) {
124
- var _event$touches$, _event$touches$2;
125
-
126
- this.event = event;
127
- this.yLast = this.y;
128
- this.xLast = this.x;
129
- var y = isTouchEvent(event) ? (_event$touches$ = event.touches[0]) === null || _event$touches$ === void 0 ? void 0 : _event$touches$.clientY : event.clientY;
130
-
131
- if (y !== this.y) {
132
- this.y = y;
133
- }
90
+ updateValues(event) {
91
+ var _event$touches$, _event$touches$2;
134
92
 
135
- var x = isTouchEvent(event) ? (_event$touches$2 = event.touches[0]) === null || _event$touches$2 === void 0 ? void 0 : _event$touches$2.clientX : event.clientX;
93
+ this.event = event;
94
+ this.yLast = this.y;
95
+ this.xLast = this.x;
96
+ var y = isTouchEvent(event) ? (_event$touches$ = event.touches[0]) === null || _event$touches$ === void 0 ? void 0 : _event$touches$.clientY : event.clientY;
136
97
 
137
- if (x !== this.x) {
138
- this.x = x;
139
- }
98
+ if (y !== this.y) {
99
+ this.y = y;
140
100
  }
141
- }, {
142
- key: "props",
143
- get: function get() {
144
- return {
145
- event: this.event,
146
- isDown: this.isDown,
147
- x: this.x,
148
- y: this.y,
149
- changed: {
150
- x: this.x !== this.xLast,
151
- y: this.y !== this.yLast
152
- },
153
- last: {
154
- x: this.xLast,
155
- y: this.yLast
156
- },
157
- delta: {
158
- x: this.x - this.xLast,
159
- y: this.y - this.yLast
160
- },
161
- progress: {
162
- x: this.x / window.innerWidth,
163
- y: this.y / window.innerHeight
164
- },
165
- max: {
166
- x: window.innerWidth,
167
- y: window.innerHeight
168
- }
169
- };
101
+
102
+ var x = isTouchEvent(event) ? (_event$touches$2 = event.touches[0]) === null || _event$touches$2 === void 0 ? void 0 : _event$touches$2.clientX : event.clientX;
103
+
104
+ if (x !== this.x) {
105
+ this.x = x;
170
106
  }
171
- }]);
107
+ }
172
108
 
173
- return Pointer;
174
- }(Service);
109
+ get props() {
110
+ return {
111
+ event: this.event,
112
+ isDown: this.isDown,
113
+ x: this.x,
114
+ y: this.y,
115
+ changed: {
116
+ x: this.x !== this.xLast,
117
+ y: this.y !== this.yLast
118
+ },
119
+ last: {
120
+ x: this.xLast,
121
+ y: this.yLast
122
+ },
123
+ delta: {
124
+ x: this.x - this.xLast,
125
+ y: this.y - this.yLast
126
+ },
127
+ progress: {
128
+ x: this.x / window.innerWidth,
129
+ y: this.y / window.innerHeight
130
+ },
131
+ max: {
132
+ x: window.innerWidth,
133
+ y: window.innerHeight
134
+ }
135
+ };
136
+ }
137
+
138
+ }
175
139
 
176
140
  var pointer = null;
177
141
  export default function usePointer() {
@@ -183,15 +147,12 @@ export default function usePointer() {
183
147
  var remove = pointer.remove.bind(pointer);
184
148
  var has = pointer.has.bind(pointer);
185
149
 
186
- var props = function props() {
187
- return pointer.props;
188
- };
150
+ var props = () => pointer.props;
189
151
 
190
152
  return {
191
- add: add,
192
- remove: remove,
193
- has: has,
194
- props: props
153
+ add,
154
+ remove,
155
+ has,
156
+ props
195
157
  };
196
- }
197
- //# sourceMappingURL=pointer.js.map
158
+ }
package/services/raf.js CHANGED
@@ -1,78 +1,51 @@
1
- import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/inherits";
5
- import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
- import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
-
9
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
-
11
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
12
-
13
- import Service from '../abstracts/Service.js';
2
+ import Service from './Service.js';
14
3
  import { getRaf, getCancelRaf } from '../utils/nextFrame.js';
15
4
 
16
- var Raf = function (_Service) {
17
- _inherits(Raf, _Service);
5
+ class Raf extends Service {
6
+ constructor() {
7
+ super();
18
8
 
19
- var _super = _createSuper(Raf);
9
+ _defineProperty(this, "isTicking", false);
20
10
 
21
- function Raf() {
22
- var _this;
11
+ _defineProperty(this, "id", 0);
23
12
 
24
- _classCallCheck(this, Raf);
13
+ _defineProperty(this, "raf", getRaf());
25
14
 
26
- _this = _super.call(this);
15
+ _defineProperty(this, "cancelRaf", getCancelRaf());
27
16
 
28
- _defineProperty(_assertThisInitialized(_this), "isTicking", false);
17
+ this.loop = this.loop.bind(this);
18
+ }
29
19
 
30
- _defineProperty(_assertThisInitialized(_this), "id", 0);
20
+ init() {
21
+ this.isTicking = true;
22
+ this.loop();
23
+ return this;
24
+ }
31
25
 
32
- _defineProperty(_assertThisInitialized(_this), "raf", getRaf());
26
+ loop() {
27
+ this.trigger(this.props);
33
28
 
34
- _defineProperty(_assertThisInitialized(_this), "cancelRaf", getCancelRaf());
29
+ if (!this.isTicking) {
30
+ return;
31
+ }
35
32
 
36
- _this.loop = _this.loop.bind(_assertThisInitialized(_this));
37
- return _this;
33
+ this.id = this.raf(this.loop);
38
34
  }
39
35
 
40
- _createClass(Raf, [{
41
- key: "init",
42
- value: function init() {
43
- this.isTicking = true;
44
- this.loop();
45
- return this;
46
- }
47
- }, {
48
- key: "loop",
49
- value: function loop() {
50
- this.trigger(this.props);
51
-
52
- if (!this.isTicking) {
53
- return;
54
- }
36
+ kill() {
37
+ this.cancelRaf(this.id);
38
+ this.isTicking = false;
39
+ return this;
40
+ }
55
41
 
56
- this.id = this.raf(this.loop);
57
- }
58
- }, {
59
- key: "kill",
60
- value: function kill() {
61
- this.cancelRaf(this.id);
62
- this.isTicking = false;
63
- return this;
64
- }
65
- }, {
66
- key: "props",
67
- get: function get() {
68
- return {
69
- time: window.performance.now()
70
- };
71
- }
72
- }]);
42
+ get props() {
43
+ return {
44
+ time: window.performance.now()
45
+ };
46
+ }
73
47
 
74
- return Raf;
75
- }(Service);
48
+ }
76
49
 
77
50
  var instance = null;
78
51
  export default function useRaf() {
@@ -89,10 +62,9 @@ export default function useRaf() {
89
62
  }
90
63
 
91
64
  return {
92
- add: add,
93
- remove: remove,
94
- has: has,
95
- props: props
65
+ add,
66
+ remove,
67
+ has,
68
+ props
96
69
  };
97
- }
98
- //# sourceMappingURL=raf.js.map
70
+ }