@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.
- package/Base/index.d.ts +29 -47
- package/Base/index.js +144 -171
- package/Base/managers/ChildrenManager.d.ts +6 -6
- package/Base/managers/ChildrenManager.js +95 -119
- package/Base/managers/EventsManager.d.ts +9 -9
- package/Base/managers/EventsManager.js +128 -161
- package/Base/managers/OptionsManager.d.ts +50 -5
- package/Base/managers/OptionsManager.js +115 -116
- package/Base/managers/RefsManager.js +62 -73
- package/Base/managers/ServicesManager.d.ts +14 -3
- package/Base/managers/ServicesManager.js +78 -77
- package/Base/utils.js +5 -8
- package/README.md +12 -70
- package/decorators/index.js +1 -2
- package/decorators/withBreakpointManager.d.ts +4 -4
- package/decorators/withBreakpointManager.js +37 -75
- package/decorators/withBreakpointObserver.d.ts +2 -2
- package/decorators/withBreakpointObserver.js +54 -77
- package/decorators/withDrag.d.ts +3 -3
- package/decorators/withDrag.js +17 -41
- package/decorators/withExtraConfig.d.ts +3 -3
- package/decorators/withExtraConfig.js +2 -24
- package/decorators/withIntersectionObserver.d.ts +2 -2
- package/decorators/withIntersectionObserver.js +17 -56
- package/decorators/withMountWhenInView.d.ts +3 -3
- package/decorators/withMountWhenInView.js +23 -51
- package/helpers/createApp.d.ts +3 -3
- package/helpers/createApp.js +10 -12
- package/helpers/importOnInteraction.d.ts +3 -3
- package/helpers/importOnInteraction.js +7 -8
- package/helpers/importWhenIdle.d.ts +3 -3
- package/helpers/importWhenIdle.js +7 -8
- package/helpers/importWhenVisible.d.ts +3 -3
- package/helpers/importWhenVisible.js +9 -16
- package/helpers/index.d.ts +1 -3
- package/helpers/index.js +1 -4
- package/helpers/utils.js +1 -2
- package/index.d.ts +14 -4
- package/index.js +4 -4
- package/index.modern.js +1 -2
- package/index.umd.js +1 -2
- package/package.json +4 -6
- package/services/Service.js +48 -67
- package/services/drag.js +143 -179
- package/services/index.js +1 -2
- package/services/key.js +55 -97
- package/services/load.d.ts +1 -1
- package/services/load.js +21 -50
- package/services/pointer.js +117 -156
- package/services/raf.js +36 -64
- package/services/resize.js +47 -86
- package/services/scroll.js +81 -120
- package/utils/collide/boundingRectToCircle.js +7 -6
- package/utils/collide/collideCircleCircle.js +1 -2
- package/utils/collide/collideCircleRect.js +1 -2
- package/utils/collide/collidePointCircle.js +1 -2
- package/utils/collide/collidePointRect.js +1 -2
- package/utils/collide/collideRectRect.js +1 -2
- package/utils/collide/index.js +1 -2
- package/utils/css/classes.js +2 -3
- package/utils/css/index.js +1 -2
- package/utils/css/matrix.js +1 -2
- package/utils/css/styles.js +3 -8
- package/utils/css/transition.js +67 -140
- package/utils/debounce.js +3 -4
- package/utils/focusTrap.js +4 -5
- package/utils/history.js +13 -20
- package/utils/index.d.ts +2 -1
- package/utils/index.js +2 -2
- package/utils/keyCodes.js +1 -2
- package/utils/math/clamp.js +1 -2
- package/utils/math/clamp01.js +1 -2
- package/utils/math/damp.js +1 -2
- package/utils/math/index.js +1 -2
- package/utils/math/inertiaFinalValue.js +1 -2
- package/utils/math/lerp.js +1 -2
- package/utils/math/map.js +1 -2
- package/utils/math/round.js +1 -2
- package/utils/memoize.d.ts +30 -0
- package/utils/memoize.js +30 -0
- package/utils/nextFrame.js +4 -9
- package/utils/object/autoBind.js +11 -19
- package/utils/object/getAllProperties.js +3 -11
- package/utils/object/index.js +1 -2
- package/utils/object/isObject.js +2 -4
- package/utils/string/index.js +1 -2
- package/utils/string/withLeadingCharacters.js +1 -2
- package/utils/string/withLeadingSlash.js +1 -2
- package/utils/string/withTrailingCharacters.js +1 -2
- package/utils/string/withTrailingSlash.js +1 -2
- package/utils/string/withoutLeadingCharacters.js +1 -2
- package/utils/string/withoutLeadingCharactersRecursive.js +1 -2
- package/utils/string/withoutLeadingSlash.js +1 -2
- package/utils/string/withoutTrailingCharacters.js +1 -2
- package/utils/string/withoutTrailingCharactersRecursive.js +1 -2
- package/utils/string/withoutTrailingSlash.js +1 -2
- package/utils/throttle.js +2 -3
- package/Base/index.js.map +0 -1
- package/Base/managers/ChildrenManager.js.map +0 -1
- package/Base/managers/EventsManager.js.map +0 -1
- package/Base/managers/OptionsManager.js.map +0 -1
- package/Base/managers/RefsManager.js.map +0 -1
- package/Base/managers/ServicesManager.js.map +0 -1
- package/Base/utils.js.map +0 -1
- package/components/Accordion/Accordion.d.ts +0 -83
- package/components/Accordion/Accordion.js +0 -121
- package/components/Accordion/Accordion.js.map +0 -1
- package/components/Accordion/AccordionItem.d.ts +0 -122
- package/components/Accordion/AccordionItem.js +0 -327
- package/components/Accordion/AccordionItem.js.map +0 -1
- package/components/Accordion/index.d.ts +0 -27
- package/components/Accordion/index.js +0 -39
- package/components/Accordion/index.js.map +0 -1
- package/components/Cursor.d.ts +0 -138
- package/components/Cursor.js +0 -167
- package/components/Cursor.js.map +0 -1
- package/components/Draggable.d.ts +0 -49
- package/components/Draggable.js +0 -77
- package/components/Draggable.js.map +0 -1
- package/components/Modal.d.ts +0 -158
- package/components/Modal.js +0 -270
- package/components/Modal.js.map +0 -1
- package/components/Tabs.d.ts +0 -108
- package/components/Tabs.js +0 -195
- package/components/Tabs.js.map +0 -1
- package/components/index.d.ts +0 -6
- package/components/index.js +0 -7
- package/components/index.js.map +0 -1
- package/decorators/index.js.map +0 -1
- package/decorators/withBreakpointManager.js.map +0 -1
- package/decorators/withBreakpointObserver.js.map +0 -1
- package/decorators/withDrag.js.map +0 -1
- package/decorators/withExtraConfig.js.map +0 -1
- package/decorators/withIntersectionObserver.js.map +0 -1
- package/decorators/withMountWhenInView.js.map +0 -1
- package/helpers/createApp.js.map +0 -1
- package/helpers/createBase.d.ts +0 -7
- package/helpers/createBase.js +0 -7
- package/helpers/createBase.js.map +0 -1
- package/helpers/defineComponent.d.ts +0 -11
- package/helpers/defineComponent.js +0 -68
- package/helpers/defineComponent.js.map +0 -1
- package/helpers/importOnInteraction.js.map +0 -1
- package/helpers/importWhenIdle.js.map +0 -1
- package/helpers/importWhenVisible.js.map +0 -1
- package/helpers/index.js.map +0 -1
- package/helpers/utils.js.map +0 -1
- package/index.js.map +0 -1
- package/index.modern.js.map +0 -1
- package/index.umd.js.map +0 -1
- package/services/Service.js.map +0 -1
- package/services/drag.js.map +0 -1
- package/services/index.js.map +0 -1
- package/services/key.js.map +0 -1
- package/services/load.js.map +0 -1
- package/services/pointer.js.map +0 -1
- package/services/raf.js.map +0 -1
- package/services/resize.js.map +0 -1
- package/services/scroll.js.map +0 -1
- package/utils/collide/boundingRectToCircle.js.map +0 -1
- package/utils/collide/collideCircleCircle.js.map +0 -1
- package/utils/collide/collideCircleRect.js.map +0 -1
- package/utils/collide/collidePointCircle.js.map +0 -1
- package/utils/collide/collidePointRect.js.map +0 -1
- package/utils/collide/collideRectRect.js.map +0 -1
- package/utils/collide/index.js.map +0 -1
- package/utils/css/classes.js.map +0 -1
- package/utils/css/index.js.map +0 -1
- package/utils/css/matrix.js.map +0 -1
- package/utils/css/styles.js.map +0 -1
- package/utils/css/transition.js.map +0 -1
- package/utils/debounce.js.map +0 -1
- package/utils/focusTrap.js.map +0 -1
- package/utils/history.js.map +0 -1
- package/utils/index.js.map +0 -1
- package/utils/keyCodes.js.map +0 -1
- package/utils/math/clamp.js.map +0 -1
- package/utils/math/clamp01.js.map +0 -1
- package/utils/math/damp.js.map +0 -1
- package/utils/math/index.js.map +0 -1
- package/utils/math/inertiaFinalValue.js.map +0 -1
- package/utils/math/lerp.js.map +0 -1
- package/utils/math/map.js.map +0 -1
- package/utils/math/round.js.map +0 -1
- package/utils/nextFrame.js.map +0 -1
- package/utils/object/autoBind.js.map +0 -1
- package/utils/object/getAllProperties.js.map +0 -1
- package/utils/object/index.js.map +0 -1
- package/utils/object/isObject.js.map +0 -1
- package/utils/string/index.js.map +0 -1
- package/utils/string/withLeadingCharacters.js.map +0 -1
- package/utils/string/withLeadingSlash.js.map +0 -1
- package/utils/string/withTrailingCharacters.js.map +0 -1
- package/utils/string/withTrailingSlash.js.map +0 -1
- package/utils/string/withoutLeadingCharacters.js.map +0 -1
- package/utils/string/withoutLeadingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutLeadingSlash.js.map +0 -1
- package/utils/string/withoutTrailingCharacters.js.map +0 -1
- package/utils/string/withoutTrailingCharactersRecursive.js.map +0 -1
- package/utils/string/withoutTrailingSlash.js.map +0 -1
- 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
|
-
|
|
17
|
-
|
|
5
|
+
class Raf extends Service {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
_defineProperty(this, "isTicking", false);
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
var _this;
|
|
11
|
+
_defineProperty(this, "id", 0);
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
_defineProperty(this, "raf", getRaf());
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
_defineProperty(this, "cancelRaf", getCancelRaf());
|
|
27
16
|
|
|
28
|
-
|
|
17
|
+
this.loop = this.loop.bind(this);
|
|
18
|
+
}
|
|
29
19
|
|
|
30
|
-
|
|
20
|
+
init() {
|
|
21
|
+
this.isTicking = true;
|
|
22
|
+
this.loop();
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
31
25
|
|
|
32
|
-
|
|
26
|
+
loop() {
|
|
27
|
+
this.trigger(this.props);
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
if (!this.isTicking) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
35
32
|
|
|
36
|
-
|
|
37
|
-
return _this;
|
|
33
|
+
this.id = this.raf(this.loop);
|
|
38
34
|
}
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
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
|
|
93
|
-
remove
|
|
94
|
-
has
|
|
95
|
-
props
|
|
65
|
+
add,
|
|
66
|
+
remove,
|
|
67
|
+
has,
|
|
68
|
+
props
|
|
96
69
|
};
|
|
97
|
-
}
|
|
98
|
-
//# sourceMappingURL=raf.js.map
|
|
70
|
+
}
|
package/services/resize.js
CHANGED
|
@@ -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
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
13
|
+
kill() {
|
|
14
|
+
window.removeEventListener('resize', this.handler);
|
|
15
|
+
return this;
|
|
23
16
|
}
|
|
24
17
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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
|
-
|
|
31
|
-
|
|
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
|
-
|
|
38
|
-
|
|
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
|
-
|
|
53
|
-
|
|
54
|
-
|
|
34
|
+
if (this.breakpointElement) {
|
|
35
|
+
props.breakpoint = this.breakpoint;
|
|
36
|
+
props.breakpoints = this.breakpoints;
|
|
37
|
+
}
|
|
55
38
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
39
|
+
return props;
|
|
40
|
+
}
|
|
59
41
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
42
|
+
get breakpointElement() {
|
|
43
|
+
return document.querySelector('[data-breakpoint]') || null;
|
|
44
|
+
}
|
|
64
45
|
|
|
65
|
-
|
|
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
|
-
|
|
91
|
-
|
|
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 =
|
|
104
|
-
return resize.props;
|
|
105
|
-
};
|
|
67
|
+
var props = () => resize.props;
|
|
106
68
|
|
|
107
69
|
return {
|
|
108
|
-
add
|
|
109
|
-
remove
|
|
110
|
-
has
|
|
111
|
-
props
|
|
70
|
+
add,
|
|
71
|
+
remove,
|
|
72
|
+
has,
|
|
73
|
+
props
|
|
112
74
|
};
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=resize.js.map
|
|
75
|
+
}
|
package/services/scroll.js
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
5
|
+
class Scroll extends Service {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
_defineProperty(this, "y", window.pageYOffset);
|
|
20
10
|
|
|
21
|
-
|
|
22
|
-
var _this;
|
|
11
|
+
_defineProperty(this, "yLast", window.pageYOffset);
|
|
23
12
|
|
|
24
|
-
|
|
13
|
+
_defineProperty(this, "x", window.pageXOffset);
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
|
|
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
|
-
|
|
18
|
+
init() {
|
|
19
|
+
document.addEventListener('scroll', this, {
|
|
20
|
+
passive: true,
|
|
21
|
+
capture: true
|
|
22
|
+
});
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
35
25
|
|
|
36
|
-
|
|
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
|
-
|
|
36
|
+
handleEvent() {
|
|
37
|
+
this.trigger(this.props);
|
|
38
|
+
this.debouncedHandler();
|
|
39
|
+
}
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
kill() {
|
|
42
|
+
document.removeEventListener('scroll', this);
|
|
43
|
+
return this;
|
|
41
44
|
}
|
|
42
45
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
119
|
-
|
|
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
|
-
|
|
128
|
-
|
|
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 =
|
|
141
|
-
return scroll.props;
|
|
142
|
-
};
|
|
104
|
+
var props = () => scroll.props;
|
|
143
105
|
|
|
144
106
|
return {
|
|
145
|
-
add
|
|
146
|
-
remove
|
|
147
|
-
has
|
|
148
|
-
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
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
}
|
package/utils/collide/index.js
CHANGED
|
@@ -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 };
|
package/utils/css/classes.js
CHANGED
|
@@ -5,7 +5,7 @@ function setClasses(element, classNames) {
|
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
classNames.split(' ').forEach(
|
|
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
|
+
}
|
package/utils/css/index.js
CHANGED
|
@@ -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 };
|
package/utils/css/matrix.js
CHANGED
|
@@ -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
|
+
}
|
package/utils/css/styles.js
CHANGED
|
@@ -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(
|
|
11
|
-
var
|
|
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
|
+
}
|