@studiometa/js-toolkit 2.0.0-beta.5 → 2.0.0-beta.9

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 (61) hide show
  1. package/Base/index.d.ts +27 -1
  2. package/Base/index.js +98 -42
  3. package/Base/managers/EventsManager.d.ts +3 -1
  4. package/Base/managers/EventsManager.js +6 -2
  5. package/Base/managers/OptionsManager.d.ts +2 -0
  6. package/Base/managers/RefsManager.d.ts +2 -0
  7. package/Base/managers/RefsManager.js +5 -0
  8. package/Base/managers/ServicesManager.d.ts +29 -4
  9. package/Base/managers/ServicesManager.js +6 -2
  10. package/README.md +13 -70
  11. package/decorators/index.d.ts +8 -9
  12. package/decorators/index.js +8 -9
  13. package/decorators/withBreakpointObserver.js +2 -2
  14. package/decorators/withDrag.js +8 -2
  15. package/decorators/withIntersectionObserver.js +4 -3
  16. package/decorators/withMountWhenInView.js +7 -4
  17. package/decorators/withScrolledInView.d.ts +4 -1
  18. package/decorators/withScrolledInView.js +56 -39
  19. package/decorators/withVue2.js +2 -2
  20. package/helpers/index.d.ts +4 -5
  21. package/helpers/index.js +4 -5
  22. package/index.d.ts +4 -21
  23. package/index.js +4 -5
  24. package/index.modern.js +1 -1
  25. package/index.umd.js +1 -1
  26. package/package.json +1 -1
  27. package/services/Service.d.ts +22 -17
  28. package/services/Service.js +12 -7
  29. package/services/drag.d.ts +4 -18
  30. package/services/drag.js +81 -104
  31. package/services/index.d.ts +13 -10
  32. package/services/index.js +7 -8
  33. package/services/key.d.ts +4 -13
  34. package/services/key.js +55 -56
  35. package/services/load.d.ts +3 -13
  36. package/services/load.js +32 -26
  37. package/services/pointer.d.ts +4 -13
  38. package/services/pointer.js +61 -64
  39. package/services/raf.d.ts +3 -13
  40. package/services/raf.js +22 -25
  41. package/services/resize.d.ts +3 -13
  42. package/services/resize.js +48 -30
  43. package/services/scroll.d.ts +3 -13
  44. package/services/scroll.js +65 -61
  45. package/utils/collide/index.d.ts +6 -7
  46. package/utils/collide/index.js +6 -7
  47. package/utils/css/index.d.ts +4 -5
  48. package/utils/css/index.js +6 -5
  49. package/utils/css/transition.js +2 -2
  50. package/utils/history.js +2 -2
  51. package/utils/index.d.ts +11 -35
  52. package/utils/index.js +11 -17
  53. package/utils/math/ease.d.ts +78 -0
  54. package/utils/math/ease.js +41 -0
  55. package/utils/math/index.d.ts +8 -8
  56. package/utils/math/index.js +8 -8
  57. package/utils/object/getAllProperties.js +1 -1
  58. package/utils/object/index.d.ts +3 -4
  59. package/utils/object/index.js +3 -4
  60. package/utils/string/index.d.ts +10 -11
  61. package/utils/string/index.js +10 -11
@@ -1,9 +1,24 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import Service from './Service.js';
2
3
  import debounce from '../utils/debounce.js';
3
4
 
4
5
  class Resize extends Service {
6
+ constructor() {
7
+ super(...arguments);
8
+
9
+ _defineProperty(this, "props", {
10
+ width: window.innerWidth,
11
+ height: window.innerHeight,
12
+ ratio: window.innerWidth / window.innerHeight,
13
+ orientation: 'square'
14
+ });
15
+
16
+ _defineProperty(this, "handler", void 0);
17
+ }
18
+
5
19
  init() {
6
20
  this.handler = debounce(() => {
21
+ this.updateProps();
7
22
  this.trigger(this.props);
8
23
  }).bind(this);
9
24
  window.addEventListener('resize', this.handler);
@@ -12,35 +27,35 @@ class Resize extends Service {
12
27
 
13
28
  kill() {
14
29
  window.removeEventListener('resize', this.handler);
15
- return this;
16
30
  }
17
31
 
18
- get props() {
19
- var props = {
20
- width: window.innerWidth,
21
- height: window.innerHeight,
22
- ratio: window.innerWidth / window.innerHeight,
23
- orientation: 'square'
24
- };
32
+ updateProps() {
33
+ this.props.width = window.innerWidth;
34
+ this.props.height = window.innerHeight;
35
+ this.props.ratio = window.innerWidth / window.innerHeight;
36
+ this.props.orientation = 'square';
25
37
 
26
- if (props.ratio > 1) {
27
- props.orientation = 'landscape';
38
+ if (this.props.ratio > 1) {
39
+ this.props.orientation = 'landscape';
28
40
  }
29
41
 
30
- if (props.ratio < 1) {
31
- props.orientation = 'portrait';
42
+ if (this.props.ratio < 1) {
43
+ this.props.orientation = 'portrait';
32
44
  }
33
45
 
34
46
  if (this.breakpointElement) {
35
- props.breakpoint = this.breakpoint;
36
- props.breakpoints = this.breakpoints;
47
+ this.props.breakpoint = this.breakpoint;
48
+ this.props.breakpoints = this.breakpoints;
49
+ } else {
50
+ this.props.breakpoint = undefined;
51
+ this.props.breakpoints = undefined;
37
52
  }
38
53
 
39
- return props;
54
+ return this.props;
40
55
  }
41
56
 
42
57
  get breakpointElement() {
43
- return document.querySelector('[data-breakpoint]') || null;
58
+ return document.querySelector('[data-breakpoint]');
44
59
  }
45
60
 
46
61
  get breakpoint() {
@@ -54,22 +69,25 @@ class Resize extends Service {
54
69
 
55
70
  }
56
71
 
57
- var resize = null;
72
+ var instance;
73
+ var resize;
58
74
  export default function useResize() {
59
75
  if (!resize) {
60
- resize = new Resize();
61
- }
62
-
63
- var add = resize.add.bind(resize);
64
- var remove = resize.remove.bind(resize);
65
- var has = resize.has.bind(resize);
76
+ if (!instance) {
77
+ instance = new Resize();
78
+ }
66
79
 
67
- var props = () => resize.props;
80
+ var add = instance.add.bind(instance);
81
+ var remove = instance.remove.bind(instance);
82
+ var has = instance.has.bind(instance);
83
+ var props = instance.updateProps.bind(instance);
84
+ resize = {
85
+ add,
86
+ remove,
87
+ has,
88
+ props
89
+ };
90
+ }
68
91
 
69
- return {
70
- add,
71
- remove,
72
- has,
73
- props
74
- };
92
+ return resize;
75
93
  }
@@ -9,10 +9,10 @@
9
9
  * props();
10
10
  * ```
11
11
  *
12
- * @return {ServiceInterface & ScrollService}
12
+ * @return {ScrollService}
13
13
  */
14
- export default function useScroll(): ServiceInterface & ScrollService;
15
- export type ServiceInterface = import('./index').ServiceInterface;
14
+ export default function useScroll(): ScrollService;
15
+ export type ScrollService = import('./index').ServiceInterface<ScrollServiceProps>;
16
16
  export type ScrollServiceProps = {
17
17
  x: number;
18
18
  y: number;
@@ -41,13 +41,3 @@ export type ScrollServiceProps = {
41
41
  y: 'UP' | 'DOWN' | 'NONE';
42
42
  };
43
43
  };
44
- export type ScrollService = {
45
- /**
46
- * Add a function to the resize service. The key must be uniq.
47
- */
48
- add: (key: string, callback: (props: ScrollServiceProps) => void) => void;
49
- /**
50
- * Get the current values of the resize service props.
51
- */
52
- props: () => ScrollServiceProps;
53
- };
@@ -6,16 +6,38 @@ class Scroll extends Service {
6
6
  constructor() {
7
7
  super(...arguments);
8
8
 
9
- _defineProperty(this, "y", window.pageYOffset);
10
-
11
- _defineProperty(this, "yLast", window.pageYOffset);
12
-
13
- _defineProperty(this, "x", window.pageXOffset);
14
-
15
- _defineProperty(this, "xLast", window.pageXOffset);
9
+ _defineProperty(this, "props", {
10
+ x: window.pageXOffset,
11
+ y: window.pageYOffset,
12
+ changed: {
13
+ x: false,
14
+ y: false
15
+ },
16
+ last: {
17
+ x: window.pageXOffset,
18
+ y: window.pageYOffset
19
+ },
20
+ delta: {
21
+ x: 0,
22
+ y: 0
23
+ },
24
+ max: {
25
+ x: (document.scrollingElement || document.body).scrollWidth - window.innerWidth,
26
+ y: (document.scrollingElement || document.body).scrollHeight - window.innerHeight
27
+ },
28
+ progress: {
29
+ x: 0,
30
+ y: 0
31
+ },
32
+ direction: {
33
+ x: 'NONE',
34
+ y: 'NONE'
35
+ }
36
+ });
16
37
  }
17
38
 
18
39
  init() {
40
+ this.updateProps();
19
41
  document.addEventListener('scroll', this, {
20
42
  passive: true,
21
43
  capture: true
@@ -25,8 +47,9 @@ class Scroll extends Service {
25
47
 
26
48
  get debouncedHandler() {
27
49
  var debounced = debounce(() => {
50
+ this.updateProps();
28
51
  this.trigger(this.props);
29
- }, 0);
52
+ }, 100);
30
53
  Object.defineProperty(this, 'debouncedHandler', {
31
54
  value: debounced
32
55
  });
@@ -34,6 +57,7 @@ class Scroll extends Service {
34
57
  }
35
58
 
36
59
  handleEvent() {
60
+ this.updateProps();
37
61
  this.trigger(this.props);
38
62
  this.debouncedHandler();
39
63
  }
@@ -43,70 +67,50 @@ class Scroll extends Service {
43
67
  return this;
44
68
  }
45
69
 
46
- get props() {
47
- this.yLast = this.y;
48
- this.xLast = this.x;
70
+ updateProps() {
71
+ var yLast = this.props.y;
72
+ var xLast = this.props.x;
49
73
 
50
- if (window.pageYOffset !== this.y) {
51
- this.y = window.pageYOffset;
74
+ if (window.pageYOffset !== this.props.y) {
75
+ this.props.y = window.pageYOffset;
52
76
  }
53
77
 
54
- if (window.pageXOffset !== this.x) {
55
- this.x = window.pageXOffset;
78
+ if (window.pageXOffset !== this.props.x) {
79
+ this.props.x = window.pageXOffset;
56
80
  }
57
81
 
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
- };
82
+ this.props.changed.x = this.props.x !== xLast;
83
+ this.props.changed.y = this.props.y !== yLast;
84
+ this.props.last.x = xLast;
85
+ this.props.last.y = yLast;
86
+ this.props.delta.x = this.props.x - xLast;
87
+ this.props.delta.y = this.props.y - yLast;
88
+ this.props.max.x = (document.scrollingElement || document.body).scrollWidth - window.innerWidth;
89
+ this.props.max.y = (document.scrollingElement || document.body).scrollHeight - window.innerHeight;
90
+ this.props.progress.x = this.props.max.x === 0 ? 1 : this.props.x / this.props.max.x;
91
+ this.props.progress.y = this.props.max.y === 0 ? 1 : this.props.y / this.props.max.y;
92
+ this.props.direction.x = this.props.x > xLast ? 'RIGHT' : this.props.x < xLast ? 'LEFT' : 'NONE';
93
+ this.props.direction.y = this.props.y > yLast ? 'DOWN' : this.props.y < yLast ? 'UP' : 'NONE';
94
+ return this.props;
90
95
  }
91
96
 
92
97
  }
93
98
 
94
- var scroll = null;
99
+ var instance;
100
+ var scroll;
95
101
  export default function useScroll() {
96
102
  if (!scroll) {
97
- scroll = new Scroll();
98
- }
99
-
100
- var add = scroll.add.bind(scroll);
101
- var remove = scroll.remove.bind(scroll);
102
- var has = scroll.has.bind(scroll);
103
+ if (!instance) {
104
+ instance = new Scroll();
105
+ }
103
106
 
104
- var props = () => scroll.props;
107
+ scroll = {
108
+ add: instance.add.bind(instance),
109
+ remove: instance.remove.bind(instance),
110
+ has: instance.has.bind(instance),
111
+ props: instance.updateProps.bind(instance)
112
+ };
113
+ }
105
114
 
106
- return {
107
- add,
108
- remove,
109
- has,
110
- props
111
- };
115
+ return scroll;
112
116
  }
@@ -1,7 +1,6 @@
1
- import boundingRectToCircle from "./boundingRectToCircle.js";
2
- import collideCircleCircle from "./collideCircleCircle.js";
3
- import collideCircleRect from "./collideCircleRect.js";
4
- import collidePointCircle from "./collidePointCircle.js";
5
- import collidePointRect from "./collidePointRect.js";
6
- import collideRectRect from "./collideRectRect.js";
7
- export { boundingRectToCircle, collideCircleCircle, collideCircleRect, collidePointCircle, collidePointRect, collideRectRect };
1
+ export { default as boundingRectToCircle } from "./boundingRectToCircle.js";
2
+ export { default as collideCircleCircle } from "./collideCircleCircle.js";
3
+ export { default as collideCircleRect } from "./collideCircleRect.js";
4
+ export { default as collidePointCircle } from "./collidePointCircle.js";
5
+ export { default as collidePointRect } from "./collidePointRect.js";
6
+ export { default as collideRectRect } from "./collideRectRect.js";
@@ -1,7 +1,6 @@
1
- import boundingRectToCircle from './boundingRectToCircle.js';
2
- import collideCircleCircle from './collideCircleCircle.js';
3
- import collideCircleRect from './collideCircleRect.js';
4
- import collidePointCircle from './collidePointCircle.js';
5
- import collidePointRect from './collidePointRect.js';
6
- import collideRectRect from './collideRectRect.js';
7
- export { boundingRectToCircle, collideCircleCircle, collideCircleRect, collidePointCircle, collidePointRect, collideRectRect };
1
+ export { default as boundingRectToCircle } from './boundingRectToCircle.js';
2
+ export { default as collideCircleCircle } from './collideCircleCircle.js';
3
+ export { default as collideCircleRect } from './collideCircleRect.js';
4
+ export { default as collidePointCircle } from './collidePointCircle.js';
5
+ export { default as collidePointRect } from './collidePointRect.js';
6
+ export { default as collideRectRect } from './collideRectRect.js';
@@ -1,5 +1,4 @@
1
- import * as classes from "./classes.js";
2
- import * as styles from "./styles.js";
3
- import matrix from "./matrix.js";
4
- import transition from "./transition.js";
5
- export { classes, styles, matrix, transition };
1
+ export * as classes from "./classes.js";
2
+ export * as styles from "./styles.js";
3
+ export { default as matrix } from "./matrix.js";
4
+ export { default as transition } from "./transition.js";
@@ -1,5 +1,6 @@
1
- import * as classes from './classes.js';
2
- import * as styles from './styles.js';
3
- import matrix from './matrix.js';
4
- import transition from './transition.js';
5
- export { classes, styles, matrix, transition };
1
+ import * as _classes from './classes.js';
2
+ export { _classes as classes };
3
+ import * as _styles from './styles.js';
4
+ export { _styles as styles };
5
+ export { default as matrix } from './matrix.js';
6
+ export { default as transition } from './transition.js';
@@ -1,9 +1,9 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
3
 
4
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
5
 
6
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
7
7
 
8
8
  import nextFrame from '../nextFrame.js';
9
9
  import * as classes from './classes.js';
package/utils/history.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
 
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
4
 
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
6
 
7
7
  import isObject from './object/isObject.js';
8
8
 
package/utils/index.d.ts CHANGED
@@ -1,35 +1,11 @@
1
- import { matrix } from "./css/index.js";
2
- import { transition } from "./css/index.js";
3
- import { collidePointRect } from "./collide/index.js";
4
- import { collideRectRect } from "./collide/index.js";
5
- import { boundingRectToCircle } from "./collide/index.js";
6
- import { collideCircleRect } from "./collide/index.js";
7
- import { collideCircleCircle } from "./collide/index.js";
8
- import { collidePointCircle } from "./collide/index.js";
9
- import { objectToURLSearchParams } from "./history.js";
10
- import { push as historyPush } from "./history.js";
11
- import { replace as historyReplace } from "./history.js";
12
- import { clamp } from "./math/index.js";
13
- import { clamp01 } from "./math/index.js";
14
- import { damp } from "./math/index.js";
15
- import { inertiaFinalValue } from "./math/index.js";
16
- import { lerp } from "./math/index.js";
17
- import { map } from "./math/index.js";
18
- import { round } from "./math/index.js";
19
- import { withLeadingCharacters } from "./string/index.js";
20
- import { withLeadingSlash } from "./string/index.js";
21
- import { withoutLeadingCharacters } from "./string/index.js";
22
- import { withoutLeadingCharactersRecursive } from "./string/index.js";
23
- import { withoutLeadingSlash } from "./string/index.js";
24
- import { withoutTrailingCharacters } from "./string/index.js";
25
- import { withoutTrailingCharactersRecursive } from "./string/index.js";
26
- import { withoutTrailingSlash } from "./string/index.js";
27
- import { withTrailingCharacters } from "./string/index.js";
28
- import { withTrailingSlash } from "./string/index.js";
29
- import debounce from "./debounce.js";
30
- import focusTrap from "./focusTrap.js";
31
- import keyCodes from "./keyCodes.js";
32
- import memoize from "./memoize.js";
33
- import nextFrame from "./nextFrame.js";
34
- import throttle from "./throttle.js";
35
- export { matrix, transition, collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle, objectToURLSearchParams, historyPush, historyReplace, clamp, clamp01, damp, inertiaFinalValue, lerp, map, round, withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash, debounce, focusTrap, keyCodes, memoize, nextFrame, throttle };
1
+ export { default as debounce } from "./debounce.js";
2
+ export { default as focusTrap } from "./focusTrap.js";
3
+ export { default as keyCodes } from "./keyCodes.js";
4
+ export { default as memoize } from "./memoize.js";
5
+ export { default as nextFrame } from "./nextFrame.js";
6
+ export { default as throttle } from "./throttle.js";
7
+ export * from "./collide/index.js";
8
+ export * from "./math/index.js";
9
+ export * from "./string/index.js";
10
+ export { matrix, transition } from "./css/index.js";
11
+ export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from "./history.js";
package/utils/index.js CHANGED
@@ -1,17 +1,11 @@
1
- import debounce from './debounce.js';
2
- import focusTrap from './focusTrap.js';
3
- import keyCodes from './keyCodes.js';
4
- import memoize from './memoize.js';
5
- import nextFrame from './nextFrame.js';
6
- import throttle from './throttle.js';
7
- import { matrix, transition } from './css/index.js';
8
- import { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle } from './collide/index.js';
9
- import { objectToURLSearchParams, push as historyPush, replace as historyReplace } from './history.js';
10
- import { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round } from './math/index.js';
11
- import { withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash } from './string/index.js';
12
- export { matrix, transition };
13
- export { collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle };
14
- export { objectToURLSearchParams, historyPush, historyReplace };
15
- export { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round };
16
- export { withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash };
17
- export { debounce, focusTrap, keyCodes, memoize, nextFrame, throttle };
1
+ export { default as debounce } from './debounce.js';
2
+ export { default as focusTrap } from './focusTrap.js';
3
+ export { default as keyCodes } from './keyCodes.js';
4
+ export { default as memoize } from './memoize.js';
5
+ export { default as nextFrame } from './nextFrame.js';
6
+ export { default as throttle } from './throttle.js';
7
+ export { matrix, transition } from './css/index.js';
8
+ export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from './history.js';
9
+ export * from './collide/index.js';
10
+ export * from './math/index.js';
11
+ export * from './string/index.js';
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @typedef {(progress: number) => number} EasingFunction
3
+ */
4
+ /**
5
+ * Create an out easing function.
6
+ *
7
+ * @param {EasingFunction} easeIn The ease in function.
8
+ * @returns {EasingFunction} The out function.
9
+ */
10
+ export function createEaseOut(easeIn: EasingFunction): EasingFunction;
11
+ /**
12
+ * Create an in-out easing function.
13
+ *
14
+ * @param {EasingFunction} easeIn The ease in function.
15
+ * @return {EasingFunction} The in-out function.
16
+ */
17
+ export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
18
+ /**
19
+ * @type {EasingFunction}
20
+ */
21
+ export function easeInQuad(progress: number): number;
22
+ /**
23
+ * Ease in cubic.
24
+ *
25
+ * @param {number} progress Progress value betwen 0 and 1.
26
+ * @return {number} Eased value between 0 and 1.
27
+ */
28
+ export function easeInCubic(progress: number): number;
29
+ /**
30
+ * Ease in quart.
31
+ *
32
+ * @param {number} progress Progress value betwen 0 and 1.
33
+ * @return {number} Eased value between 0 and 1.
34
+ */
35
+ export function easeInQuart(progress: number): number;
36
+ /**
37
+ * Ease in quint.
38
+ *
39
+ * @param {number} progress Progress value betwen 0 and 1.
40
+ * @return {number} Eased value between 0 and 1.
41
+ */
42
+ export function easeInQuint(progress: number): number;
43
+ /**
44
+ * Ease in sine.
45
+ *
46
+ * @param {number} progress Progress value betwen 0 and 1.
47
+ * @return {number} Eased value between 0 and 1.
48
+ */
49
+ export function easeInSine(progress: number): number;
50
+ /**
51
+ * Ease in circ.
52
+ *
53
+ * @param {number} progress Progress value betwen 0 and 1.
54
+ * @return {number} Eased value between 0 and 1.
55
+ */
56
+ export function easeInCirc(progress: number): number;
57
+ /**
58
+ * Ease in exponential.
59
+ *
60
+ * @param {number} progress Progress value betwen 0 and 1.
61
+ * @return {number} Eased value between 0 and 1.
62
+ */
63
+ export function easeInExpo(progress: number): number;
64
+ export function easeOutQuad(progress: number): number;
65
+ export function easeInOutQuad(progress: number): number;
66
+ export function easeOutCubic(progress: number): number;
67
+ export function easeInOutCubic(progress: number): number;
68
+ export function easeOutQuart(progress: number): number;
69
+ export function easeInOutQuart(progress: number): number;
70
+ export function easeOutQuint(progress: number): number;
71
+ export function easeInOutQuint(progress: number): number;
72
+ export function easeOutSine(progress: number): number;
73
+ export function easeInOutSine(progress: number): number;
74
+ export function easeOutCirc(progress: number): number;
75
+ export function easeInOutCirc(progress: number): number;
76
+ export function easeOutExpo(progress: number): number;
77
+ export function easeInOutExpo(progress: number): number;
78
+ export type EasingFunction = (progress: number) => number;
@@ -0,0 +1,41 @@
1
+ export function createEaseOut(easeIn) {
2
+ return progress => 1 - easeIn(1 - progress);
3
+ }
4
+ export function createEaseInOut(easeIn) {
5
+ return progress => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
6
+ }
7
+ export function easeInQuad(progress) {
8
+ return progress ** 2;
9
+ }
10
+ export var easeOutQuad = createEaseOut(easeInQuad);
11
+ export var easeInOutQuad = createEaseInOut(easeInQuad);
12
+ export function easeInCubic(progress) {
13
+ return progress ** 3;
14
+ }
15
+ export var easeOutCubic = createEaseOut(easeInCubic);
16
+ export var easeInOutCubic = createEaseInOut(easeInCubic);
17
+ export function easeInQuart(progress) {
18
+ return progress ** 4;
19
+ }
20
+ export var easeOutQuart = createEaseOut(easeInQuart);
21
+ export var easeInOutQuart = createEaseInOut(easeInQuart);
22
+ export function easeInQuint(progress) {
23
+ return progress ** 5;
24
+ }
25
+ export var easeOutQuint = createEaseOut(easeInQuint);
26
+ export var easeInOutQuint = createEaseInOut(easeInQuint);
27
+ export function easeInSine(progress) {
28
+ return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
29
+ }
30
+ export var easeOutSine = createEaseOut(easeInSine);
31
+ export var easeInOutSine = createEaseInOut(easeInSine);
32
+ export function easeInCirc(progress) {
33
+ return -(Math.sqrt(1 - progress * progress) - 1);
34
+ }
35
+ export var easeOutCirc = createEaseOut(easeInCirc);
36
+ export var easeInOutCirc = createEaseInOut(easeInCirc);
37
+ export function easeInExpo(progress) {
38
+ return 2 ** (10 * (progress - 1));
39
+ }
40
+ export var easeOutExpo = createEaseOut(easeInExpo);
41
+ export var easeInOutExpo = createEaseInOut(easeInExpo);
@@ -1,8 +1,8 @@
1
- import clamp from "./clamp.js";
2
- import clamp01 from "./clamp01.js";
3
- import damp from "./damp.js";
4
- import inertiaFinalValue from "./inertiaFinalValue.js";
5
- import lerp from "./lerp.js";
6
- import map from "./map.js";
7
- import round from "./round.js";
8
- export { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round };
1
+ export { default as clamp } from "./clamp.js";
2
+ export { default as clamp01 } from "./clamp01.js";
3
+ export { default as damp } from "./damp.js";
4
+ export { default as inertiaFinalValue } from "./inertiaFinalValue.js";
5
+ export { default as lerp } from "./lerp.js";
6
+ export { default as map } from "./map.js";
7
+ export { default as round } from "./round.js";
8
+ export * from "./ease.js";
@@ -1,8 +1,8 @@
1
- import clamp from './clamp.js';
2
- import clamp01 from './clamp01.js';
3
- import damp from './damp.js';
4
- import inertiaFinalValue from './inertiaFinalValue.js';
5
- import lerp from './lerp.js';
6
- import map from './map.js';
7
- import round from './round.js';
8
- export { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round };
1
+ export { default as clamp } from './clamp.js';
2
+ export { default as clamp01 } from './clamp01.js';
3
+ export { default as damp } from './damp.js';
4
+ export { default as inertiaFinalValue } from './inertiaFinalValue.js';
5
+ export { default as lerp } from './lerp.js';
6
+ export { default as map } from './map.js';
7
+ export { default as round } from './round.js';
8
+ export * from './ease.js';
@@ -3,7 +3,7 @@ export default function getAllProperties(object) {
3
3
  var testFn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
4
4
  var proto = Object.getPrototypeOf(object);
5
5
 
6
- if (proto === Object.prototype) {
6
+ if (proto === Object.prototype || proto === null) {
7
7
  return props;
8
8
  }
9
9
 
@@ -1,4 +1,3 @@
1
- import autoBind from "./autoBind.js";
2
- import getAllProperties from "./getAllProperties.js";
3
- import isObject from "./isObject.js";
4
- export { autoBind, getAllProperties, isObject };
1
+ export { default as autoBind } from "./autoBind.js";
2
+ export { default as getAllProperties } from "./getAllProperties.js";
3
+ export { default as isObject } from "./isObject.js";