@studiometa/js-toolkit 2.0.0-alpha.1 → 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 (201) hide show
  1. package/Base/index.d.ts +29 -47
  2. package/Base/index.js +144 -171
  3. package/Base/managers/ChildrenManager.d.ts +6 -6
  4. package/Base/managers/ChildrenManager.js +95 -119
  5. package/Base/managers/EventsManager.d.ts +9 -9
  6. package/Base/managers/EventsManager.js +128 -161
  7. package/Base/managers/OptionsManager.d.ts +50 -5
  8. package/Base/managers/OptionsManager.js +115 -116
  9. package/Base/managers/RefsManager.js +62 -73
  10. package/Base/managers/ServicesManager.d.ts +14 -3
  11. package/Base/managers/ServicesManager.js +78 -77
  12. package/Base/utils.js +5 -8
  13. package/README.md +12 -70
  14. package/decorators/index.js +1 -2
  15. package/decorators/withBreakpointManager.d.ts +4 -4
  16. package/decorators/withBreakpointManager.js +37 -75
  17. package/decorators/withBreakpointObserver.d.ts +2 -2
  18. package/decorators/withBreakpointObserver.js +54 -77
  19. package/decorators/withDrag.d.ts +3 -3
  20. package/decorators/withDrag.js +17 -41
  21. package/decorators/withExtraConfig.d.ts +3 -3
  22. package/decorators/withExtraConfig.js +2 -24
  23. package/decorators/withIntersectionObserver.d.ts +2 -2
  24. package/decorators/withIntersectionObserver.js +17 -56
  25. package/decorators/withMountWhenInView.d.ts +3 -3
  26. package/decorators/withMountWhenInView.js +23 -51
  27. package/helpers/createApp.d.ts +3 -3
  28. package/helpers/createApp.js +10 -12
  29. package/helpers/importOnInteraction.d.ts +3 -3
  30. package/helpers/importOnInteraction.js +7 -8
  31. package/helpers/importWhenIdle.d.ts +3 -3
  32. package/helpers/importWhenIdle.js +7 -8
  33. package/helpers/importWhenVisible.d.ts +3 -3
  34. package/helpers/importWhenVisible.js +9 -16
  35. package/helpers/index.d.ts +1 -3
  36. package/helpers/index.js +1 -4
  37. package/helpers/utils.js +1 -2
  38. package/index.d.ts +14 -4
  39. package/index.js +4 -4
  40. package/index.modern.js +1 -2
  41. package/index.umd.js +1 -2
  42. package/package.json +4 -6
  43. package/services/Service.js +48 -67
  44. package/services/drag.js +143 -179
  45. package/services/index.js +1 -2
  46. package/services/key.js +55 -97
  47. package/services/load.d.ts +1 -1
  48. package/services/load.js +21 -50
  49. package/services/pointer.js +117 -156
  50. package/services/raf.js +36 -64
  51. package/services/resize.js +47 -86
  52. package/services/scroll.js +81 -120
  53. package/utils/collide/boundingRectToCircle.js +7 -6
  54. package/utils/collide/collideCircleCircle.js +1 -2
  55. package/utils/collide/collideCircleRect.js +1 -2
  56. package/utils/collide/collidePointCircle.js +1 -2
  57. package/utils/collide/collidePointRect.js +1 -2
  58. package/utils/collide/collideRectRect.js +1 -2
  59. package/utils/collide/index.js +1 -2
  60. package/utils/css/classes.js +2 -3
  61. package/utils/css/index.js +1 -2
  62. package/utils/css/matrix.js +1 -2
  63. package/utils/css/styles.js +3 -8
  64. package/utils/css/transition.js +67 -140
  65. package/utils/debounce.js +3 -4
  66. package/utils/focusTrap.js +4 -5
  67. package/utils/history.js +13 -20
  68. package/utils/index.d.ts +2 -1
  69. package/utils/index.js +2 -2
  70. package/utils/keyCodes.js +1 -2
  71. package/utils/math/clamp.js +1 -2
  72. package/utils/math/clamp01.js +1 -2
  73. package/utils/math/damp.js +1 -2
  74. package/utils/math/index.js +1 -2
  75. package/utils/math/inertiaFinalValue.js +1 -2
  76. package/utils/math/lerp.js +1 -2
  77. package/utils/math/map.js +1 -2
  78. package/utils/math/round.js +1 -2
  79. package/utils/memoize.d.ts +30 -0
  80. package/utils/memoize.js +30 -0
  81. package/utils/nextFrame.js +4 -9
  82. package/utils/object/autoBind.js +11 -19
  83. package/utils/object/getAllProperties.js +3 -11
  84. package/utils/object/index.js +1 -2
  85. package/utils/object/isObject.js +2 -4
  86. package/utils/string/index.js +1 -2
  87. package/utils/string/withLeadingCharacters.js +1 -2
  88. package/utils/string/withLeadingSlash.js +1 -2
  89. package/utils/string/withTrailingCharacters.js +1 -2
  90. package/utils/string/withTrailingSlash.js +1 -2
  91. package/utils/string/withoutLeadingCharacters.js +1 -2
  92. package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
  93. package/utils/string/withoutLeadingSlash.js +1 -2
  94. package/utils/string/withoutTrailingCharacters.js +1 -2
  95. package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
  96. package/utils/string/withoutTrailingSlash.js +1 -2
  97. package/utils/throttle.js +2 -3
  98. package/Base/index.js.map +0 -1
  99. package/Base/managers/ChildrenManager.js.map +0 -1
  100. package/Base/managers/EventsManager.js.map +0 -1
  101. package/Base/managers/OptionsManager.js.map +0 -1
  102. package/Base/managers/RefsManager.js.map +0 -1
  103. package/Base/managers/ServicesManager.js.map +0 -1
  104. package/Base/utils.js.map +0 -1
  105. package/components/Accordion/Accordion.d.ts +0 -83
  106. package/components/Accordion/Accordion.js +0 -121
  107. package/components/Accordion/Accordion.js.map +0 -1
  108. package/components/Accordion/AccordionItem.d.ts +0 -122
  109. package/components/Accordion/AccordionItem.js +0 -327
  110. package/components/Accordion/AccordionItem.js.map +0 -1
  111. package/components/Accordion/index.d.ts +0 -27
  112. package/components/Accordion/index.js +0 -39
  113. package/components/Accordion/index.js.map +0 -1
  114. package/components/Cursor.d.ts +0 -138
  115. package/components/Cursor.js +0 -167
  116. package/components/Cursor.js.map +0 -1
  117. package/components/Draggable.d.ts +0 -49
  118. package/components/Draggable.js +0 -77
  119. package/components/Draggable.js.map +0 -1
  120. package/components/Modal.d.ts +0 -158
  121. package/components/Modal.js +0 -270
  122. package/components/Modal.js.map +0 -1
  123. package/components/Tabs.d.ts +0 -108
  124. package/components/Tabs.js +0 -195
  125. package/components/Tabs.js.map +0 -1
  126. package/components/index.d.ts +0 -6
  127. package/components/index.js +0 -7
  128. package/components/index.js.map +0 -1
  129. package/decorators/index.js.map +0 -1
  130. package/decorators/withBreakpointManager.js.map +0 -1
  131. package/decorators/withBreakpointObserver.js.map +0 -1
  132. package/decorators/withDrag.js.map +0 -1
  133. package/decorators/withExtraConfig.js.map +0 -1
  134. package/decorators/withIntersectionObserver.js.map +0 -1
  135. package/decorators/withMountWhenInView.js.map +0 -1
  136. package/helpers/createApp.js.map +0 -1
  137. package/helpers/createBase.d.ts +0 -7
  138. package/helpers/createBase.js +0 -7
  139. package/helpers/createBase.js.map +0 -1
  140. package/helpers/defineComponent.d.ts +0 -11
  141. package/helpers/defineComponent.js +0 -68
  142. package/helpers/defineComponent.js.map +0 -1
  143. package/helpers/importOnInteraction.js.map +0 -1
  144. package/helpers/importWhenIdle.js.map +0 -1
  145. package/helpers/importWhenVisible.js.map +0 -1
  146. package/helpers/index.js.map +0 -1
  147. package/helpers/utils.js.map +0 -1
  148. package/index.js.map +0 -1
  149. package/index.modern.js.map +0 -1
  150. package/index.umd.js.map +0 -1
  151. package/services/Service.js.map +0 -1
  152. package/services/drag.js.map +0 -1
  153. package/services/index.js.map +0 -1
  154. package/services/key.js.map +0 -1
  155. package/services/load.js.map +0 -1
  156. package/services/pointer.js.map +0 -1
  157. package/services/raf.js.map +0 -1
  158. package/services/resize.js.map +0 -1
  159. package/services/scroll.js.map +0 -1
  160. package/utils/collide/boundingRectToCircle.js.map +0 -1
  161. package/utils/collide/collideCircleCircle.js.map +0 -1
  162. package/utils/collide/collideCircleRect.js.map +0 -1
  163. package/utils/collide/collidePointCircle.js.map +0 -1
  164. package/utils/collide/collidePointRect.js.map +0 -1
  165. package/utils/collide/collideRectRect.js.map +0 -1
  166. package/utils/collide/index.js.map +0 -1
  167. package/utils/css/classes.js.map +0 -1
  168. package/utils/css/index.js.map +0 -1
  169. package/utils/css/matrix.js.map +0 -1
  170. package/utils/css/styles.js.map +0 -1
  171. package/utils/css/transition.js.map +0 -1
  172. package/utils/debounce.js.map +0 -1
  173. package/utils/focusTrap.js.map +0 -1
  174. package/utils/history.js.map +0 -1
  175. package/utils/index.js.map +0 -1
  176. package/utils/keyCodes.js.map +0 -1
  177. package/utils/math/clamp.js.map +0 -1
  178. package/utils/math/clamp01.js.map +0 -1
  179. package/utils/math/damp.js.map +0 -1
  180. package/utils/math/index.js.map +0 -1
  181. package/utils/math/inertiaFinalValue.js.map +0 -1
  182. package/utils/math/lerp.js.map +0 -1
  183. package/utils/math/map.js.map +0 -1
  184. package/utils/math/round.js.map +0 -1
  185. package/utils/nextFrame.js.map +0 -1
  186. package/utils/object/autoBind.js.map +0 -1
  187. package/utils/object/getAllProperties.js.map +0 -1
  188. package/utils/object/index.js.map +0 -1
  189. package/utils/object/isObject.js.map +0 -1
  190. package/utils/string/index.js.map +0 -1
  191. package/utils/string/withLeadingCharacters.js.map +0 -1
  192. package/utils/string/withLeadingSlash.js.map +0 -1
  193. package/utils/string/withTrailingCharacters.js.map +0 -1
  194. package/utils/string/withTrailingSlash.js.map +0 -1
  195. package/utils/string/withoutLeadingCharacters.js.map +0 -1
  196. package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
  197. package/utils/string/withoutLeadingSlash.js.map +0 -1
  198. package/utils/string/withoutTrailingCharacters.js.map +0 -1
  199. package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
  200. package/utils/string/withoutTrailingSlash.js.map +0 -1
  201. package/utils/throttle.js.map +0 -1
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
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
+ }
@@ -1,94 +1,58 @@
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";
6
-
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); }; }
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
1
  import Service from './Service.js';
12
2
  import debounce from '../utils/debounce.js';
13
3
 
14
- var Resize = function (_Service) {
15
- _inherits(Resize, _Service);
16
-
17
- var _super = _createSuper(Resize);
18
-
19
- function Resize() {
20
- _classCallCheck(this, Resize);
4
+ class Resize extends Service {
5
+ init() {
6
+ this.handler = debounce(() => {
7
+ this.trigger(this.props);
8
+ }).bind(this);
9
+ window.addEventListener('resize', this.handler);
10
+ return this;
11
+ }
21
12
 
22
- return _super.apply(this, arguments);
13
+ kill() {
14
+ window.removeEventListener('resize', this.handler);
15
+ return this;
23
16
  }
24
17
 
25
- _createClass(Resize, [{
26
- key: "init",
27
- value: function init() {
28
- var _this = this;
18
+ get props() {
19
+ var props = {
20
+ width: window.innerWidth,
21
+ height: window.innerHeight,
22
+ ratio: window.innerWidth / window.innerHeight,
23
+ orientation: 'square'
24
+ };
29
25
 
30
- this.handler = debounce(function () {
31
- _this.trigger(_this.props);
32
- }).bind(this);
33
- window.addEventListener('resize', this.handler);
34
- return this;
26
+ if (props.ratio > 1) {
27
+ props.orientation = 'landscape';
35
28
  }
36
- }, {
37
- key: "kill",
38
- value: function kill() {
39
- window.removeEventListener('resize', this.handler);
40
- return this;
29
+
30
+ if (props.ratio < 1) {
31
+ props.orientation = 'portrait';
41
32
  }
42
- }, {
43
- key: "props",
44
- get: function get() {
45
- var props = {
46
- width: window.innerWidth,
47
- height: window.innerHeight,
48
- ratio: window.innerWidth / window.innerHeight,
49
- orientation: 'square'
50
- };
51
33
 
52
- if (props.ratio > 1) {
53
- props.orientation = 'landscape';
54
- }
34
+ if (this.breakpointElement) {
35
+ props.breakpoint = this.breakpoint;
36
+ props.breakpoints = this.breakpoints;
37
+ }
55
38
 
56
- if (props.ratio < 1) {
57
- props.orientation = 'portrait';
58
- }
39
+ return props;
40
+ }
59
41
 
60
- if (this.breakpointElement) {
61
- props.breakpoint = this.breakpoint;
62
- props.breakpoints = this.breakpoints;
63
- }
42
+ get breakpointElement() {
43
+ return document.querySelector('[data-breakpoint]') || null;
44
+ }
64
45
 
65
- return props;
66
- }
67
- }, {
68
- key: "breakpointElement",
69
- get: function get() {
70
- return document.querySelector('[data-breakpoint]') || null;
71
- }
72
- }, {
73
- key: "breakpoint",
74
- get: function get() {
75
- return window.getComputedStyle(this.breakpointElement, '::before').getPropertyValue('content').replace(/"/g, '');
76
- }
77
- }, {
78
- key: "breakpoints",
79
- get: function get() {
80
- var breakpoints = window.getComputedStyle(this.breakpointElement, '::after').getPropertyValue('content').replace(/"/g, '');
81
- return breakpoints.split(',');
82
- }
83
- }, {
84
- key: "canUseResizeObserver",
85
- get: function get() {
86
- return typeof window.ResizeObserver !== 'undefined';
87
- }
88
- }]);
46
+ get breakpoint() {
47
+ return window.getComputedStyle(this.breakpointElement, '::before').getPropertyValue('content').replace(/"/g, '');
48
+ }
89
49
 
90
- return Resize;
91
- }(Service);
50
+ get breakpoints() {
51
+ var breakpoints = window.getComputedStyle(this.breakpointElement, '::after').getPropertyValue('content').replace(/"/g, '');
52
+ return breakpoints.split(',');
53
+ }
54
+
55
+ }
92
56
 
93
57
  var resize = null;
94
58
  export default function useResize() {
@@ -100,15 +64,12 @@ export default function useResize() {
100
64
  var remove = resize.remove.bind(resize);
101
65
  var has = resize.has.bind(resize);
102
66
 
103
- var props = function props() {
104
- return resize.props;
105
- };
67
+ var props = () => resize.props;
106
68
 
107
69
  return {
108
- add: add,
109
- remove: remove,
110
- has: has,
111
- props: props
70
+ add,
71
+ remove,
72
+ has,
73
+ props
112
74
  };
113
- }
114
- //# sourceMappingURL=resize.js.map
75
+ }
@@ -1,131 +1,95 @@
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
2
  import Service from './Service.js';
14
3
  import debounce from '../utils/debounce.js';
15
4
 
16
- var Scroll = function (_Service) {
17
- _inherits(Scroll, _Service);
5
+ class Scroll extends Service {
6
+ constructor() {
7
+ super(...arguments);
18
8
 
19
- var _super = _createSuper(Scroll);
9
+ _defineProperty(this, "y", window.pageYOffset);
20
10
 
21
- function Scroll() {
22
- var _this;
11
+ _defineProperty(this, "yLast", window.pageYOffset);
23
12
 
24
- _classCallCheck(this, Scroll);
13
+ _defineProperty(this, "x", window.pageXOffset);
25
14
 
26
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
27
- args[_key] = arguments[_key];
28
- }
29
-
30
- _this = _super.call.apply(_super, [this].concat(args));
31
-
32
- _defineProperty(_assertThisInitialized(_this), "y", window.pageYOffset);
15
+ _defineProperty(this, "xLast", window.pageXOffset);
16
+ }
33
17
 
34
- _defineProperty(_assertThisInitialized(_this), "yLast", window.pageYOffset);
18
+ init() {
19
+ document.addEventListener('scroll', this, {
20
+ passive: true,
21
+ capture: true
22
+ });
23
+ return this;
24
+ }
35
25
 
36
- _defineProperty(_assertThisInitialized(_this), "x", window.pageXOffset);
26
+ get debouncedHandler() {
27
+ var debounced = debounce(() => {
28
+ this.trigger(this.props);
29
+ }, 0);
30
+ Object.defineProperty(this, 'debouncedHandler', {
31
+ value: debounced
32
+ });
33
+ return debounced;
34
+ }
37
35
 
38
- _defineProperty(_assertThisInitialized(_this), "xLast", window.pageXOffset);
36
+ handleEvent() {
37
+ this.trigger(this.props);
38
+ this.debouncedHandler();
39
+ }
39
40
 
40
- return _this;
41
+ kill() {
42
+ document.removeEventListener('scroll', this);
43
+ return this;
41
44
  }
42
45
 
43
- _createClass(Scroll, [{
44
- key: "init",
45
- value: function init() {
46
- document.addEventListener('scroll', this, {
47
- passive: true,
48
- capture: true
49
- });
50
- return this;
51
- }
52
- }, {
53
- key: "debouncedHandler",
54
- get: function get() {
55
- var _this2 = this;
56
-
57
- var debounced = debounce(function () {
58
- _this2.trigger(_this2.props);
59
- }, 0);
60
- Object.defineProperty(this, 'debouncedHandler', {
61
- value: debounced
62
- });
63
- return debounced;
64
- }
65
- }, {
66
- key: "handleEvent",
67
- value: function handleEvent() {
68
- this.trigger(this.props);
69
- this.debouncedHandler();
70
- }
71
- }, {
72
- key: "kill",
73
- value: function kill() {
74
- document.removeEventListener('scroll', this);
75
- return this;
76
- }
77
- }, {
78
- key: "props",
79
- get: function get() {
80
- this.yLast = this.y;
81
- this.xLast = this.x;
82
-
83
- if (window.pageYOffset !== this.y) {
84
- this.y = window.pageYOffset;
85
- }
86
-
87
- if (window.pageXOffset !== this.x) {
88
- this.x = window.pageXOffset;
89
- }
90
-
91
- return {
92
- x: this.x,
93
- y: this.y,
94
- changed: {
95
- x: this.x !== this.xLast,
96
- y: this.y !== this.yLast
97
- },
98
- last: {
99
- x: this.xLast,
100
- y: this.yLast
101
- },
102
- delta: {
103
- x: this.x - this.xLast,
104
- y: this.y - this.yLast
105
- },
106
- progress: {
107
- x: this.max.x === 0 ? 1 : this.x / this.max.x,
108
- y: this.max.y === 0 ? 1 : this.y / this.max.y
109
- },
110
- direction: {
111
- x: this.x > this.xLast ? 'RIGHT' : this.x < this.xLast ? 'LEFT' : 'NONE',
112
- y: this.y > this.yLast ? 'DOWN' : this.y < this.yLast ? 'UP' : 'NONE'
113
- },
114
- max: this.max
115
- };
46
+ get props() {
47
+ this.yLast = this.y;
48
+ this.xLast = this.x;
49
+
50
+ if (window.pageYOffset !== this.y) {
51
+ this.y = window.pageYOffset;
116
52
  }
117
- }, {
118
- key: "max",
119
- get: function get() {
120
- return {
121
- x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,
122
- y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight
123
- };
53
+
54
+ if (window.pageXOffset !== this.x) {
55
+ this.x = window.pageXOffset;
124
56
  }
125
- }]);
126
57
 
127
- return Scroll;
128
- }(Service);
58
+ return {
59
+ x: this.x,
60
+ y: this.y,
61
+ changed: {
62
+ x: this.x !== this.xLast,
63
+ y: this.y !== this.yLast
64
+ },
65
+ last: {
66
+ x: this.xLast,
67
+ y: this.yLast
68
+ },
69
+ delta: {
70
+ x: this.x - this.xLast,
71
+ y: this.y - this.yLast
72
+ },
73
+ progress: {
74
+ x: this.max.x === 0 ? 1 : this.x / this.max.x,
75
+ y: this.max.y === 0 ? 1 : this.y / this.max.y
76
+ },
77
+ direction: {
78
+ x: this.x > this.xLast ? 'RIGHT' : this.x < this.xLast ? 'LEFT' : 'NONE',
79
+ y: this.y > this.yLast ? 'DOWN' : this.y < this.yLast ? 'UP' : 'NONE'
80
+ },
81
+ max: this.max
82
+ };
83
+ }
84
+
85
+ get max() {
86
+ return {
87
+ x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,
88
+ y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight
89
+ };
90
+ }
91
+
92
+ }
129
93
 
130
94
  var scroll = null;
131
95
  export default function useScroll() {
@@ -137,15 +101,12 @@ export default function useScroll() {
137
101
  var remove = scroll.remove.bind(scroll);
138
102
  var has = scroll.has.bind(scroll);
139
103
 
140
- var props = function props() {
141
- return scroll.props;
142
- };
104
+ var props = () => scroll.props;
143
105
 
144
106
  return {
145
- add: add,
146
- remove: remove,
147
- has: has,
148
- props: props
107
+ add,
108
+ remove,
109
+ has,
110
+ props
149
111
  };
150
- }
151
- //# sourceMappingURL=scroll.js.map
112
+ }
@@ -1,8 +1,10 @@
1
1
  export default function collidePointRect(_ref) {
2
- var x = _ref.x,
3
- y = _ref.y,
4
- width = _ref.width,
5
- height = _ref.height;
2
+ var {
3
+ x,
4
+ y,
5
+ width,
6
+ height
7
+ } = _ref;
6
8
  var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
7
9
  if (width !== height && !force) throw new Error('Initial DOMElement is not a square. Please use the force mode.');
8
10
  return {
@@ -10,5 +12,4 @@ export default function collidePointRect(_ref) {
10
12
  y: y + height / 2,
11
13
  radius: (width + height) / 4
12
14
  };
13
- }
14
- //# sourceMappingURL=boundingRectToCircle.js.map
15
+ }
@@ -8,5 +8,4 @@ export default function collideCircleCircle(circle1, circle2) {
8
8
  }
9
9
 
10
10
  return false;
11
- }
12
- //# sourceMappingURL=collideCircleCircle.js.map
11
+ }
@@ -23,5 +23,4 @@ export default function collideCircleRect(circle, rect) {
23
23
  }
24
24
 
25
25
  return false;
26
- }
27
- //# sourceMappingURL=collideCircleRect.js.map
26
+ }
@@ -3,5 +3,4 @@ export default function collidePointCircle(point, circle) {
3
3
  var distY = point.y - circle.y;
4
4
  var distance = Math.sqrt(distX * distX + distY * distY);
5
5
  return distance <= circle.radius;
6
- }
7
- //# sourceMappingURL=collidePointCircle.js.map
6
+ }
@@ -1,4 +1,3 @@
1
1
  export default function collidePointRect(point, rect) {
2
2
  return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
3
- }
4
- //# sourceMappingURL=collidePointRect.js.map
3
+ }
@@ -1,4 +1,3 @@
1
1
  export default function collideRectRect(rect1, rect2) {
2
2
  return rect1.x + rect1.width >= rect2.x && rect1.x <= rect2.x + rect2.width && rect1.y + rect1.height >= rect2.y && rect1.y <= rect2.y + rect2.height;
3
- }
4
- //# sourceMappingURL=collideRectRect.js.map
3
+ }
@@ -4,5 +4,4 @@ import boundingRectToCircle from './boundingRectToCircle.js';
4
4
  import collideCircleRect from './collideCircleRect.js';
5
5
  import collideCircleCircle from './collideCircleCircle.js';
6
6
  import collidePointCircle from './collidePointCircle.js';
7
- export { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle };
8
- //# sourceMappingURL=index.js.map
7
+ export { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle };
@@ -5,7 +5,7 @@ function setClasses(element, classNames) {
5
5
  return;
6
6
  }
7
7
 
8
- classNames.split(' ').forEach(function (className) {
8
+ classNames.split(' ').forEach(className => {
9
9
  element.classList[method](className);
10
10
  });
11
11
  }
@@ -18,5 +18,4 @@ export function remove(element, classNames) {
18
18
  }
19
19
  export function toggle(element, classNames) {
20
20
  setClasses(element, classNames, 'toggle');
21
- }
22
- //# sourceMappingURL=classes.js.map
21
+ }
@@ -2,5 +2,4 @@ import * as classes from './classes.js';
2
2
  import * as styles from './styles.js';
3
3
  import matrix from './matrix.js';
4
4
  import transition from './transition.js';
5
- export { classes, styles, matrix, transition };
6
- //# sourceMappingURL=index.js.map
5
+ export { classes, styles, matrix, transition };
@@ -3,5 +3,4 @@ export default function matrix(transform) {
3
3
 
4
4
  transform = transform || {};
5
5
  return "matrix(".concat((_transform$scaleX = transform.scaleX) !== null && _transform$scaleX !== void 0 ? _transform$scaleX : 1, ", ").concat((_transform$skewY = transform.skewY) !== null && _transform$skewY !== void 0 ? _transform$skewY : 0, ", ").concat((_transform$skewX = transform.skewX) !== null && _transform$skewX !== void 0 ? _transform$skewX : 0, ", ").concat((_transform$scaleY = transform.scaleY) !== null && _transform$scaleY !== void 0 ? _transform$scaleY : 1, ", ").concat((_transform$translateX = transform.translateX) !== null && _transform$translateX !== void 0 ? _transform$translateX : 0, ", ").concat((_transform$translateY = transform.translateY) !== null && _transform$translateY !== void 0 ? _transform$translateY : 0, ")");
6
- }
7
- //# sourceMappingURL=matrix.js.map
6
+ }
@@ -1,4 +1,3 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import isObject from '../object/isObject.js';
3
2
  export default function setStyles(element, styles) {
4
3
  var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'add';
@@ -7,11 +6,8 @@ export default function setStyles(element, styles) {
7
6
  return;
8
7
  }
9
8
 
10
- Object.entries(styles).forEach(function (_ref) {
11
- var _ref2 = _slicedToArray(_ref, 2),
12
- prop = _ref2[0],
13
- value = _ref2[1];
14
-
9
+ Object.entries(styles).forEach(_ref => {
10
+ var [prop, value] = _ref;
15
11
  element.style[prop] = method === 'add' ? value : '';
16
12
  });
17
13
  }
@@ -20,5 +16,4 @@ export function add(element, styles) {
20
16
  }
21
17
  export function remove(element, styles) {
22
18
  setStyles(element, styles, 'remove');
23
- }
24
- //# sourceMappingURL=styles.js.map
19
+ }