@studiometa/js-toolkit 2.0.0-beta.9 → 2.0.0-rc.1
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.cjs +285 -0
- package/Base/index.d.ts +11 -2
- package/Base/index.js +114 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +9 -1
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +174 -0
- package/Base/managers/OptionsManager.d.ts +9 -5
- package/Base/managers/OptionsManager.js +60 -90
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +28 -38
- package/Base/managers/ServicesManager.cjs +131 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.js +12 -11
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +20 -8
- package/decorators/withBreakpointManager.cjs +85 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +115 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +36 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +14 -0
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +60 -0
- package/decorators/withVue2.js +26 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +2 -2
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +35 -0
- package/helpers/index.js +10 -4
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.js +7 -4
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +213 -0
- package/services/drag.d.ts +1 -0
- package/services/drag.js +64 -68
- package/services/index.cjs +41 -0
- package/services/index.js +16 -7
- package/services/key.cjs +104 -0
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.js +14 -6
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +10 -9
- package/utils/css/classes.js +18 -14
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +2 -2
- package/utils/css/index.js +13 -6
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +6 -18
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +89 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +4 -1
- package/utils/index.js +32 -11
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.js +50 -25
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +4 -3
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.js +8 -3
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.js +22 -10
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/boundingRectToCircle.js
|
|
20
|
+
var boundingRectToCircle_exports = {};
|
|
21
|
+
__export(boundingRectToCircle_exports, {
|
|
22
|
+
default: () => boundingRectToCircle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(boundingRectToCircle_exports);
|
|
25
|
+
function boundingRectToCircle({ x, y, width, height }, force = false) {
|
|
26
|
+
if (width !== height && !force)
|
|
27
|
+
throw new Error("Initial DOMElement is not a square. Please use the force mode.");
|
|
28
|
+
return {
|
|
29
|
+
x: x + width / 2,
|
|
30
|
+
y: y + height / 2,
|
|
31
|
+
radius: (width + height) / 4
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* @param {Boolean} force Force usage of non-square DOMElements
|
|
12
12
|
* @return {Circle} Circle object that can be used in collides functions
|
|
13
13
|
*/
|
|
14
|
-
export default function
|
|
14
|
+
export default function boundingRectToCircle({ x, y, width, height }: Partial<DOMRect>, force?: boolean): Circle;
|
|
15
15
|
export type Circle = {
|
|
16
16
|
/**
|
|
17
17
|
* Circle's x position
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
y,
|
|
5
|
-
width,
|
|
6
|
-
height
|
|
7
|
-
} = _ref;
|
|
8
|
-
var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
9
|
-
if (width !== height && !force) throw new Error('Initial DOMElement is not a square. Please use the force mode.');
|
|
1
|
+
function boundingRectToCircle({ x, y, width, height }, force = false) {
|
|
2
|
+
if (width !== height && !force)
|
|
3
|
+
throw new Error("Initial DOMElement is not a square. Please use the force mode.");
|
|
10
4
|
return {
|
|
11
5
|
x: x + width / 2,
|
|
12
6
|
y: y + height / 2,
|
|
13
7
|
radius: (width + height) / 4
|
|
14
8
|
};
|
|
15
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
boundingRectToCircle as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/collideCircleCircle.js
|
|
20
|
+
var collideCircleCircle_exports = {};
|
|
21
|
+
__export(collideCircleCircle_exports, {
|
|
22
|
+
default: () => collideCircleCircle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collideCircleCircle_exports);
|
|
25
|
+
function collideCircleCircle(circle1, circle2) {
|
|
26
|
+
const distX = circle1.x - circle2.x;
|
|
27
|
+
const distY = circle1.y - circle2.y;
|
|
28
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
29
|
+
if (distance <= circle1.radius + circle2.radius) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
function collideCircleCircle(circle1, circle2) {
|
|
2
|
+
const distX = circle1.x - circle2.x;
|
|
3
|
+
const distY = circle1.y - circle2.y;
|
|
4
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
6
5
|
if (distance <= circle1.radius + circle2.radius) {
|
|
7
6
|
return true;
|
|
8
7
|
}
|
|
9
|
-
|
|
10
8
|
return false;
|
|
11
|
-
}
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
collideCircleCircle as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/collideCircleRect.js
|
|
20
|
+
var collideCircleRect_exports = {};
|
|
21
|
+
__export(collideCircleRect_exports, {
|
|
22
|
+
default: () => collideCircleRect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collideCircleRect_exports);
|
|
25
|
+
function collideCircleRect(circle, rect) {
|
|
26
|
+
let testX = circle.x;
|
|
27
|
+
let testY = circle.y;
|
|
28
|
+
if (circle.x < rect.x) {
|
|
29
|
+
testX = rect.x;
|
|
30
|
+
} else if (circle.x > rect.x + rect.width) {
|
|
31
|
+
testX = rect.x + rect.width;
|
|
32
|
+
}
|
|
33
|
+
if (circle.y < rect.y) {
|
|
34
|
+
testY = rect.y;
|
|
35
|
+
} else if (circle.y > rect.y + rect.height) {
|
|
36
|
+
testY = rect.y + rect.height;
|
|
37
|
+
}
|
|
38
|
+
const distX = circle.x - testX;
|
|
39
|
+
const distY = circle.y - testY;
|
|
40
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
41
|
+
if (distance <= circle.radius) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,26 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function collideCircleRect(circle, rect) {
|
|
2
|
+
let testX = circle.x;
|
|
3
|
+
let testY = circle.y;
|
|
5
4
|
if (circle.x < rect.x) {
|
|
6
5
|
testX = rect.x;
|
|
7
6
|
} else if (circle.x > rect.x + rect.width) {
|
|
8
7
|
testX = rect.x + rect.width;
|
|
9
8
|
}
|
|
10
|
-
|
|
11
9
|
if (circle.y < rect.y) {
|
|
12
10
|
testY = rect.y;
|
|
13
11
|
} else if (circle.y > rect.y + rect.height) {
|
|
14
12
|
testY = rect.y + rect.height;
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
var distance = Math.sqrt(distX * distX + distY * distY);
|
|
20
|
-
|
|
14
|
+
const distX = circle.x - testX;
|
|
15
|
+
const distY = circle.y - testY;
|
|
16
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
21
17
|
if (distance <= circle.radius) {
|
|
22
18
|
return true;
|
|
23
19
|
}
|
|
24
|
-
|
|
25
20
|
return false;
|
|
26
|
-
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
collideCircleRect as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/collidePointCircle.js
|
|
20
|
+
var collidePointCircle_exports = {};
|
|
21
|
+
__export(collidePointCircle_exports, {
|
|
22
|
+
default: () => collidePointCircle
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collidePointCircle_exports);
|
|
25
|
+
function collidePointCircle(point, circle) {
|
|
26
|
+
const distX = point.x - circle.x;
|
|
27
|
+
const distY = point.y - circle.y;
|
|
28
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
29
|
+
return distance <= circle.radius;
|
|
30
|
+
}
|
|
31
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
function collidePointCircle(point, circle) {
|
|
2
|
+
const distX = point.x - circle.x;
|
|
3
|
+
const distY = point.y - circle.y;
|
|
4
|
+
const distance = Math.sqrt(distX * distX + distY * distY);
|
|
5
5
|
return distance <= circle.radius;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
collidePointCircle as default
|
|
9
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/collidePointRect.js
|
|
20
|
+
var collidePointRect_exports = {};
|
|
21
|
+
__export(collidePointRect_exports, {
|
|
22
|
+
default: () => collidePointRect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collidePointRect_exports);
|
|
25
|
+
function collidePointRect(point, rect) {
|
|
26
|
+
return point.x >= rect.x && point.x <= rect.x + rect.width && point.y >= rect.y && point.y <= rect.y + rect.height;
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
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
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
collidePointRect as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/collide/collideRectRect.js
|
|
20
|
+
var collideRectRect_exports = {};
|
|
21
|
+
__export(collideRectRect_exports, {
|
|
22
|
+
default: () => collideRectRect
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(collideRectRect_exports);
|
|
25
|
+
function collideRectRect(rect1, rect2) {
|
|
26
|
+
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;
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
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
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
collideRectRect as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/js-toolkit/utils/collide/index.js
|
|
23
|
+
var collide_exports = {};
|
|
24
|
+
__export(collide_exports, {
|
|
25
|
+
boundingRectToCircle: () => import_boundingRectToCircle.default,
|
|
26
|
+
collideCircleCircle: () => import_collideCircleCircle.default,
|
|
27
|
+
collideCircleRect: () => import_collideCircleRect.default,
|
|
28
|
+
collidePointCircle: () => import_collidePointCircle.default,
|
|
29
|
+
collidePointRect: () => import_collidePointRect.default,
|
|
30
|
+
collideRectRect: () => import_collideRectRect.default
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(collide_exports);
|
|
33
|
+
var import_boundingRectToCircle = __toESM(require("./boundingRectToCircle.cjs"), 1);
|
|
34
|
+
var import_collideCircleCircle = __toESM(require("./collideCircleCircle.cjs"), 1);
|
|
35
|
+
var import_collideCircleRect = __toESM(require("./collideCircleRect.cjs"), 1);
|
|
36
|
+
var import_collidePointCircle = __toESM(require("./collidePointCircle.cjs"), 1);
|
|
37
|
+
var import_collidePointRect = __toESM(require("./collidePointRect.cjs"), 1);
|
|
38
|
+
var import_collideRectRect = __toESM(require("./collideRectRect.cjs"), 1);
|
|
39
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/collide/index.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { default as default2 } from "./boundingRectToCircle.js";
|
|
2
|
+
import { default as default3 } from "./collideCircleCircle.js";
|
|
3
|
+
import { default as default4 } from "./collideCircleRect.js";
|
|
4
|
+
import { default as default5 } from "./collidePointCircle.js";
|
|
5
|
+
import { default as default6 } from "./collidePointRect.js";
|
|
6
|
+
import { default as default7 } from "./collideRectRect.js";
|
|
7
|
+
export {
|
|
8
|
+
default2 as boundingRectToCircle,
|
|
9
|
+
default3 as collideCircleCircle,
|
|
10
|
+
default4 as collideCircleRect,
|
|
11
|
+
default5 as collidePointCircle,
|
|
12
|
+
default6 as collidePointRect,
|
|
13
|
+
default7 as collideRectRect
|
|
14
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/css/classes.js
|
|
20
|
+
var classes_exports = {};
|
|
21
|
+
__export(classes_exports, {
|
|
22
|
+
add: () => add,
|
|
23
|
+
remove: () => remove,
|
|
24
|
+
toggle: () => toggle
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(classes_exports);
|
|
27
|
+
function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
28
|
+
if (!element || !classNames) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
|
|
32
|
+
if (method !== "toggle") {
|
|
33
|
+
element.classList[method](...normalizedClassNames);
|
|
34
|
+
} else {
|
|
35
|
+
normalizedClassNames.forEach((className) => element.classList[method](className, forceToggle));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function add(element, classNames) {
|
|
39
|
+
setClasses(element, classNames);
|
|
40
|
+
}
|
|
41
|
+
function remove(element, classNames) {
|
|
42
|
+
setClasses(element, classNames, "remove");
|
|
43
|
+
}
|
|
44
|
+
function toggle(element, classNames, force = void 0) {
|
|
45
|
+
setClasses(element, classNames, "toggle", force);
|
|
46
|
+
}
|
|
47
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/classes.d.ts
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add class names to an element.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
4
|
+
* @param {HTMLElement} element The element to update.
|
|
5
|
+
* @param {string|string[]} classNames A string of class names.
|
|
6
6
|
* @return {void}
|
|
7
7
|
*/
|
|
8
|
-
export function add(element: HTMLElement, classNames: string): void;
|
|
8
|
+
export function add(element: HTMLElement, classNames: string | string[]): void;
|
|
9
9
|
/**
|
|
10
10
|
* Remove class names from an element.
|
|
11
11
|
*
|
|
12
|
-
* @param {HTMLElement}
|
|
13
|
-
* @param {
|
|
12
|
+
* @param {HTMLElement} element The element to update.
|
|
13
|
+
* @param {string|string[]} classNames A string of class names.
|
|
14
14
|
* @return {void}
|
|
15
15
|
*/
|
|
16
|
-
export function remove(element: HTMLElement, classNames: string): void;
|
|
16
|
+
export function remove(element: HTMLElement, classNames: string | string[]): void;
|
|
17
17
|
/**
|
|
18
18
|
* Toggle class names from an element.
|
|
19
19
|
*
|
|
20
|
-
* @param {HTMLElement}
|
|
21
|
-
* @param {
|
|
20
|
+
* @param {HTMLElement} element The element to update.
|
|
21
|
+
* @param {string|string[]} classNames A string of class names.
|
|
22
|
+
* @param {boolean} [force] Force toggle?
|
|
22
23
|
* @return {void}
|
|
23
24
|
*/
|
|
24
|
-
export function toggle(element: HTMLElement, classNames: string): void;
|
|
25
|
+
export function toggle(element: HTMLElement, classNames: string | string[], force?: boolean): void;
|
package/utils/css/classes.js
CHANGED
|
@@ -1,21 +1,25 @@
|
|
|
1
|
-
function setClasses(element, classNames) {
|
|
2
|
-
var method = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'add';
|
|
3
|
-
|
|
1
|
+
function setClasses(element, classNames, method = "add", forceToggle = void 0) {
|
|
4
2
|
if (!element || !classNames) {
|
|
5
3
|
return;
|
|
6
4
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
element.classList[method](
|
|
10
|
-
}
|
|
5
|
+
const normalizedClassNames = Array.isArray(classNames) ? classNames : classNames.split(" ");
|
|
6
|
+
if (method !== "toggle") {
|
|
7
|
+
element.classList[method](...normalizedClassNames);
|
|
8
|
+
} else {
|
|
9
|
+
normalizedClassNames.forEach((className) => element.classList[method](className, forceToggle));
|
|
10
|
+
}
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
export function add(element, classNames) {
|
|
12
|
+
function add(element, classNames) {
|
|
14
13
|
setClasses(element, classNames);
|
|
15
14
|
}
|
|
16
|
-
|
|
17
|
-
setClasses(element, classNames,
|
|
15
|
+
function remove(element, classNames) {
|
|
16
|
+
setClasses(element, classNames, "remove");
|
|
17
|
+
}
|
|
18
|
+
function toggle(element, classNames, force = void 0) {
|
|
19
|
+
setClasses(element, classNames, "toggle", force);
|
|
18
20
|
}
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
export {
|
|
22
|
+
add,
|
|
23
|
+
remove,
|
|
24
|
+
toggle
|
|
25
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/js-toolkit/utils/css/index.js
|
|
23
|
+
var css_exports = {};
|
|
24
|
+
__export(css_exports, {
|
|
25
|
+
addClass: () => import_classes.add,
|
|
26
|
+
addStyle: () => import_styles.add,
|
|
27
|
+
matrix: () => import_matrix.default,
|
|
28
|
+
removeClass: () => import_classes.remove,
|
|
29
|
+
removeStyle: () => import_styles.remove,
|
|
30
|
+
toggleClass: () => import_classes.toggle,
|
|
31
|
+
transition: () => import_transition.default
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(css_exports);
|
|
34
|
+
var import_classes = require("./classes.cjs");
|
|
35
|
+
var import_styles = require("./styles.cjs");
|
|
36
|
+
var import_matrix = __toESM(require("./matrix.cjs"), 1);
|
|
37
|
+
var import_transition = __toESM(require("./transition.cjs"), 1);
|
|
38
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * as classes from "./classes.js";
|
|
2
|
-
export * as styles from "./styles.js";
|
|
3
1
|
export { default as matrix } from "./matrix.js";
|
|
4
2
|
export { default as transition } from "./transition.js";
|
|
3
|
+
export { add as addClass, remove as removeClass, toggle as toggleClass } from "./classes.js";
|
|
4
|
+
export { add as addStyle, remove as removeStyle } from "./styles.js";
|
package/utils/css/index.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
|
|
1
|
+
import { add, remove, toggle } from "./classes.js";
|
|
2
|
+
import { add as add2, remove as remove2 } from "./styles.js";
|
|
3
|
+
import { default as default2 } from "./matrix.js";
|
|
4
|
+
import { default as default3 } from "./transition.js";
|
|
5
|
+
export {
|
|
6
|
+
add as addClass,
|
|
7
|
+
add2 as addStyle,
|
|
8
|
+
default2 as matrix,
|
|
9
|
+
remove as removeClass,
|
|
10
|
+
remove2 as removeStyle,
|
|
11
|
+
toggle as toggleClass,
|
|
12
|
+
default3 as transition
|
|
13
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/css/matrix.js
|
|
20
|
+
var matrix_exports = {};
|
|
21
|
+
__export(matrix_exports, {
|
|
22
|
+
default: () => matrix
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(matrix_exports);
|
|
25
|
+
function matrix(transform) {
|
|
26
|
+
var _a, _b, _c, _d, _e, _f;
|
|
27
|
+
transform = transform || {};
|
|
28
|
+
return `matrix(${(_a = transform.scaleX) != null ? _a : 1}, ${(_b = transform.skewY) != null ? _b : 0}, ${(_c = transform.skewX) != null ? _c : 0}, ${(_d = transform.scaleY) != null ? _d : 1}, ${(_e = transform.translateX) != null ? _e : 0}, ${(_f = transform.translateY) != null ? _f : 0})`;
|
|
29
|
+
}
|
|
30
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/css/matrix.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
1
|
+
function matrix(transform) {
|
|
2
|
+
var _a, _b, _c, _d, _e, _f;
|
|
4
3
|
transform = transform || {};
|
|
5
|
-
return
|
|
6
|
-
}
|
|
4
|
+
return `matrix(${(_a = transform.scaleX) != null ? _a : 1}, ${(_b = transform.skewY) != null ? _b : 0}, ${(_c = transform.skewX) != null ? _c : 0}, ${(_d = transform.scaleY) != null ? _d : 1}, ${(_e = transform.translateX) != null ? _e : 0}, ${(_f = transform.translateY) != null ? _f : 0})`;
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
matrix as default
|
|
8
|
+
};
|