@thienvu18/designable-shared 2.0.0
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/LICENSE.md +20 -0
- package/README.md +1 -0
- package/esm/animation.d.ts +2 -0
- package/esm/animation.js +33 -0
- package/esm/array.d.ts +37 -0
- package/esm/array.js +111 -0
- package/esm/clone.d.ts +4 -0
- package/esm/clone.js +97 -0
- package/esm/compose.d.ts +1 -0
- package/esm/compose.js +7 -0
- package/esm/coordinate.d.ts +106 -0
- package/esm/coordinate.js +473 -0
- package/esm/element.d.ts +6 -0
- package/esm/element.js +135 -0
- package/esm/event.d.ts +96 -0
- package/esm/event.js +212 -0
- package/esm/globalThisPolyfill.d.ts +1 -0
- package/esm/globalThisPolyfill.js +22 -0
- package/esm/index.d.ts +17 -0
- package/esm/index.js +17 -0
- package/esm/instanceof.d.ts +1 -0
- package/esm/instanceof.js +11 -0
- package/esm/keycode.d.ts +147 -0
- package/esm/keycode.js +150 -0
- package/esm/lru.d.ts +73 -0
- package/esm/lru.js +293 -0
- package/esm/observer.d.ts +9 -0
- package/esm/observer.js +43 -0
- package/esm/request-idle.d.ts +10 -0
- package/esm/request-idle.js +8 -0
- package/esm/scroller.d.ts +10 -0
- package/esm/scroller.js +82 -0
- package/esm/subscribable.d.ts +14 -0
- package/esm/subscribable.js +48 -0
- package/esm/types.d.ts +13 -0
- package/esm/types.js +21 -0
- package/esm/uid.d.ts +1 -0
- package/esm/uid.js +9 -0
- package/lib/animation.d.ts +2 -0
- package/lib/animation.js +38 -0
- package/lib/array.d.ts +37 -0
- package/lib/array.js +125 -0
- package/lib/clone.d.ts +4 -0
- package/lib/clone.js +102 -0
- package/lib/compose.d.ts +1 -0
- package/lib/compose.js +11 -0
- package/lib/coordinate.d.ts +106 -0
- package/lib/coordinate.js +502 -0
- package/lib/element.d.ts +6 -0
- package/lib/element.js +143 -0
- package/lib/event.d.ts +96 -0
- package/lib/event.js +217 -0
- package/lib/globalThisPolyfill.d.ts +1 -0
- package/lib/globalThisPolyfill.js +25 -0
- package/lib/index.d.ts +17 -0
- package/lib/index.js +33 -0
- package/lib/instanceof.d.ts +1 -0
- package/lib/instanceof.js +15 -0
- package/lib/keycode.d.ts +147 -0
- package/lib/keycode.js +154 -0
- package/lib/lru.d.ts +73 -0
- package/lib/lru.js +297 -0
- package/lib/observer.d.ts +9 -0
- package/lib/observer.js +47 -0
- package/lib/request-idle.d.ts +10 -0
- package/lib/request-idle.js +13 -0
- package/lib/scroller.d.ts +10 -0
- package/lib/scroller.js +88 -0
- package/lib/subscribable.d.ts +14 -0
- package/lib/subscribable.js +52 -0
- package/lib/types.d.ts +13 -0
- package/lib/types.js +29 -0
- package/lib/uid.d.ts +1 -0
- package/lib/uid.js +13 -0
- package/package.json +36 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015-present, Alibaba Group Holding Limited. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @thienvu18/designable-shared
|
package/esm/animation.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const createUniformSpeedAnimation = (speed = 10, callback) => {
|
|
2
|
+
let request = null;
|
|
3
|
+
let startTime = null;
|
|
4
|
+
const start = () => {
|
|
5
|
+
if (request)
|
|
6
|
+
return;
|
|
7
|
+
request = requestAnimationFrame((timestamp) => {
|
|
8
|
+
if (startTime === null) {
|
|
9
|
+
startTime = timestamp;
|
|
10
|
+
}
|
|
11
|
+
const deltaTime = timestamp - startTime;
|
|
12
|
+
const delta = (deltaTime / 1000) * speed;
|
|
13
|
+
callback(delta);
|
|
14
|
+
request = null;
|
|
15
|
+
start();
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
start();
|
|
19
|
+
return () => {
|
|
20
|
+
if (request) {
|
|
21
|
+
cancelAnimationFrame(request);
|
|
22
|
+
request = null;
|
|
23
|
+
}
|
|
24
|
+
startTime = null;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
//越接近阈值,速度越小,越远离阈值,速度越大
|
|
28
|
+
export const calcSpeedFactor = (delta = 0, threshold = Infinity) => {
|
|
29
|
+
if (threshold >= delta) {
|
|
30
|
+
return (threshold - delta) / threshold;
|
|
31
|
+
}
|
|
32
|
+
return 0;
|
|
33
|
+
};
|
package/esm/array.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
type EachArrayIterator<T> = (currentValue: T, key: number) => void | boolean;
|
|
2
|
+
type EachStringIterator = (currentValue: string, key: number) => void | boolean;
|
|
3
|
+
type EachObjectIterator<T = any> = (currentValue: T, key: string) => void | boolean;
|
|
4
|
+
type MapArrayIterator<TItem, TResult> = (currentValue: TItem, key: number) => TResult;
|
|
5
|
+
type MapStringIterator<TResult> = (currentValue: string, key: number) => TResult;
|
|
6
|
+
type MapObjectIterator<TItem, TResult> = (currentValue: TItem, key: string) => TResult;
|
|
7
|
+
type MemoArrayIterator<T, U> = (previousValue: U, currentValue: T, key: number) => U;
|
|
8
|
+
type MemoStringIterator<T> = (previousValue: T, currentValue: string, key: number) => T;
|
|
9
|
+
type MemoObjectIterator<TValue, TResult> = (previousValue: TResult, currentValue: TValue, key: string) => TResult;
|
|
10
|
+
export declare const toArr: (val: any) => any[];
|
|
11
|
+
export declare function each(val: string, iterator: EachStringIterator, revert?: boolean): void;
|
|
12
|
+
export declare function each<T>(val: T[], iterator: EachArrayIterator<T>, revert?: boolean): void;
|
|
13
|
+
export declare function each<T extends {}, TValue = T[keyof T]>(val: T, iterator: EachObjectIterator<TValue>, revert?: boolean): void;
|
|
14
|
+
export declare function map<T>(val: string, iterator: MapStringIterator<T>, revert?: boolean): any;
|
|
15
|
+
export declare function map<TItem, TResult>(val: TItem[], iterator: MapArrayIterator<TItem, TResult>, revert?: boolean): any;
|
|
16
|
+
export declare function map<T extends {}, TResult>(val: T, iterator: MapObjectIterator<T[keyof T], TResult>, revert?: boolean): any;
|
|
17
|
+
export declare function reduce<T, U>(val: T[], iterator: MemoArrayIterator<T, U>, accumulator?: U, revert?: boolean): U;
|
|
18
|
+
export declare function reduce<T>(val: string, iterator: MemoStringIterator<T>, accumulator?: T, revert?: boolean): T;
|
|
19
|
+
export declare function reduce<T extends {}, TValue = T[keyof T], TResult = any>(val: T, iterator: MemoObjectIterator<TValue, TResult>, accumulator?: TResult, revert?: boolean): TResult;
|
|
20
|
+
export declare function every<T extends string>(val: T, iterator: EachStringIterator, revert?: boolean): boolean;
|
|
21
|
+
export declare function every<T>(val: T[], iterator: EachArrayIterator<T>, revert?: boolean): boolean;
|
|
22
|
+
export declare function every<T extends {}>(val: T, iterator: EachObjectIterator, revert?: boolean): boolean;
|
|
23
|
+
export declare function some<T extends string>(val: T, iterator: EachStringIterator, revert?: boolean): boolean;
|
|
24
|
+
export declare function some<T>(val: T[], iterator: EachArrayIterator<T>, revert?: boolean): boolean;
|
|
25
|
+
export declare function some<T extends {}>(val: T, iterator: EachObjectIterator, revert?: boolean): boolean;
|
|
26
|
+
export declare function findIndex<T extends string>(val: T, iterator: EachStringIterator, revert?: boolean): number;
|
|
27
|
+
export declare function findIndex<T>(val: T[], iterator: EachArrayIterator<T>, revert?: boolean): number;
|
|
28
|
+
export declare function findIndex<T extends {}>(val: T, iterator: EachObjectIterator, revert?: boolean): keyof T;
|
|
29
|
+
export declare function find<T extends string>(val: T, iterator: EachStringIterator, revert?: boolean): any;
|
|
30
|
+
export declare function find<T>(val: T[], iterator: EachArrayIterator<T>, revert?: boolean): T;
|
|
31
|
+
export declare function find<T extends {}>(val: T, iterator: EachObjectIterator, revert?: boolean): T[keyof T];
|
|
32
|
+
export declare function includes<T extends string>(val: T, searchElement: string, revert?: boolean): boolean;
|
|
33
|
+
export declare function includes<T>(val: T[], searchElement: T, revert?: boolean): boolean;
|
|
34
|
+
export declare function includesWith<T extends string>(val: T, search: (item: string) => boolean): boolean;
|
|
35
|
+
export declare function includesWith<T>(val: T[], search: (item: T) => boolean): boolean;
|
|
36
|
+
export declare const flat: <T>(array: (T | T[])[]) => T[];
|
|
37
|
+
export {};
|
package/esm/array.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { isArr, isObj, isStr } from './types';
|
|
2
|
+
export const toArr = (val) => (isArr(val) ? val : val ? [val] : []);
|
|
3
|
+
export function each(val, iterator, revert) {
|
|
4
|
+
if (isArr(val) || isStr(val)) {
|
|
5
|
+
if (revert) {
|
|
6
|
+
for (let i = val.length - 1; i >= 0; i--) {
|
|
7
|
+
if (iterator(val[i], i) === false) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
for (let i = 0; i < val.length; i++) {
|
|
14
|
+
if (iterator(val[i], i) === false) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
else if (isObj(val)) {
|
|
21
|
+
let key;
|
|
22
|
+
for (key in val) {
|
|
23
|
+
if (Object.hasOwnProperty.call(val, key)) {
|
|
24
|
+
if (iterator(val[key], key) === false) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function map(val, iterator, revert) {
|
|
32
|
+
const res = isArr(val) || isStr(val) ? [] : {};
|
|
33
|
+
each(val, (item, key) => {
|
|
34
|
+
const value = iterator(item, key);
|
|
35
|
+
if (isArr(res)) {
|
|
36
|
+
;
|
|
37
|
+
res.push(value);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
res[key] = value;
|
|
41
|
+
}
|
|
42
|
+
}, revert);
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
export function reduce(val, iterator, accumulator, revert) {
|
|
46
|
+
let result = accumulator;
|
|
47
|
+
each(val, (item, key) => {
|
|
48
|
+
result = iterator(result, item, key);
|
|
49
|
+
}, revert);
|
|
50
|
+
return result;
|
|
51
|
+
}
|
|
52
|
+
export function every(val, iterator, revert) {
|
|
53
|
+
let res = true;
|
|
54
|
+
each(val, (item, key) => {
|
|
55
|
+
if (!iterator(item, key)) {
|
|
56
|
+
res = false;
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
}, revert);
|
|
60
|
+
return res;
|
|
61
|
+
}
|
|
62
|
+
export function some(val, iterator, revert) {
|
|
63
|
+
let res = false;
|
|
64
|
+
each(val, (item, key) => {
|
|
65
|
+
if (iterator(item, key)) {
|
|
66
|
+
res = true;
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
}, revert);
|
|
70
|
+
return res;
|
|
71
|
+
}
|
|
72
|
+
export function findIndex(val, iterator, revert) {
|
|
73
|
+
let res = -1;
|
|
74
|
+
each(val, (item, key) => {
|
|
75
|
+
if (iterator(item, key)) {
|
|
76
|
+
res = key;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}, revert);
|
|
80
|
+
return res;
|
|
81
|
+
}
|
|
82
|
+
export function find(val, iterator, revert) {
|
|
83
|
+
let res;
|
|
84
|
+
each(val, (item, key) => {
|
|
85
|
+
if (iterator(item, key)) {
|
|
86
|
+
res = item;
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}, revert);
|
|
90
|
+
return res;
|
|
91
|
+
}
|
|
92
|
+
export function includes(val, searchElement, revert) {
|
|
93
|
+
if (isStr(val))
|
|
94
|
+
return val.includes(searchElement);
|
|
95
|
+
return some(val, (item) => item === searchElement, revert);
|
|
96
|
+
}
|
|
97
|
+
export function includesWith(val, search) {
|
|
98
|
+
if (isArr(val)) {
|
|
99
|
+
return val.some((item) => search(item));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export const flat = (array) => {
|
|
106
|
+
return toArr(array).reduce((buf, item) => {
|
|
107
|
+
if (isArr(item))
|
|
108
|
+
return buf.concat(flat(item));
|
|
109
|
+
return buf.concat(item);
|
|
110
|
+
}, []);
|
|
111
|
+
};
|
package/esm/clone.d.ts
ADDED
package/esm/clone.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { isFn } from './types';
|
|
2
|
+
import { instOf } from './instanceof';
|
|
3
|
+
const NATIVE_KEYS = [
|
|
4
|
+
['Map', (map) => new Map(map)],
|
|
5
|
+
['WeakMap', (map) => new WeakMap(map)],
|
|
6
|
+
['WeakSet', (set) => new WeakSet(set)],
|
|
7
|
+
['Set', (set) => new Set(set)],
|
|
8
|
+
['Date', (date) => new Date(date)],
|
|
9
|
+
'FileList',
|
|
10
|
+
'File',
|
|
11
|
+
'URL',
|
|
12
|
+
'RegExp',
|
|
13
|
+
[
|
|
14
|
+
'Promise',
|
|
15
|
+
(promise) => new Promise((resolve, reject) => promise.then(resolve, reject)),
|
|
16
|
+
],
|
|
17
|
+
];
|
|
18
|
+
const isNativeObject = (values) => {
|
|
19
|
+
for (let i = 0; i < NATIVE_KEYS.length; i++) {
|
|
20
|
+
const item = NATIVE_KEYS[i];
|
|
21
|
+
if (Array.isArray(item) && item[0]) {
|
|
22
|
+
if (instOf(values, item[0])) {
|
|
23
|
+
return item[1] ? item[1] : item[0];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
if (instOf(values, item)) {
|
|
28
|
+
return item;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export const shallowClone = (values) => {
|
|
34
|
+
let nativeClone;
|
|
35
|
+
if (Array.isArray(values)) {
|
|
36
|
+
return values.slice(0);
|
|
37
|
+
}
|
|
38
|
+
else if (isNativeObject(values)) {
|
|
39
|
+
nativeClone = isNativeObject(values);
|
|
40
|
+
return isFn(nativeClone) ? nativeClone(values) : values;
|
|
41
|
+
}
|
|
42
|
+
else if (typeof values === 'object' && !!values) {
|
|
43
|
+
return {
|
|
44
|
+
...values,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
export const clone = (values, filter) => {
|
|
49
|
+
let nativeClone;
|
|
50
|
+
if (Array.isArray(values)) {
|
|
51
|
+
return values.map((item) => clone(item, filter));
|
|
52
|
+
}
|
|
53
|
+
else if (isNativeObject(values)) {
|
|
54
|
+
nativeClone = isNativeObject(values);
|
|
55
|
+
return isFn(nativeClone) ? nativeClone(values) : values;
|
|
56
|
+
}
|
|
57
|
+
else if (typeof values === 'object' && !!values) {
|
|
58
|
+
if ('$$typeof' in values && '_owner' in values) {
|
|
59
|
+
return values;
|
|
60
|
+
}
|
|
61
|
+
if (values._isAMomentObject) {
|
|
62
|
+
return values;
|
|
63
|
+
}
|
|
64
|
+
if (values._isJSONSchemaObject) {
|
|
65
|
+
return values;
|
|
66
|
+
}
|
|
67
|
+
if (isFn(values.toJS)) {
|
|
68
|
+
return values;
|
|
69
|
+
}
|
|
70
|
+
if (isFn(values.toJSON)) {
|
|
71
|
+
return values;
|
|
72
|
+
}
|
|
73
|
+
if (Object.getOwnPropertySymbols(values || {}).length) {
|
|
74
|
+
return values;
|
|
75
|
+
}
|
|
76
|
+
const res = {};
|
|
77
|
+
for (const key in values) {
|
|
78
|
+
if (Object.hasOwnProperty.call(values, key)) {
|
|
79
|
+
if (isFn(filter)) {
|
|
80
|
+
if (filter(values[key], key)) {
|
|
81
|
+
res[key] = clone(values[key], filter);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
res[key] = values[key];
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
res[key] = clone(values[key], filter);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return values;
|
|
96
|
+
}
|
|
97
|
+
};
|
package/esm/compose.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const compose: (...fns: ((payload: any) => any)[]) => (payload: any) => any;
|
package/esm/compose.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export interface IPoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
export interface ISize {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ILineSegment {
|
|
10
|
+
start: IPoint;
|
|
11
|
+
end: IPoint;
|
|
12
|
+
}
|
|
13
|
+
export interface IRectEdgeLines {
|
|
14
|
+
v: ILineSegment[];
|
|
15
|
+
h: ILineSegment[];
|
|
16
|
+
}
|
|
17
|
+
export declare function isRect(rect: any): rect is IRect;
|
|
18
|
+
export declare function isPoint(val: any): val is IPoint;
|
|
19
|
+
export declare function isLineSegment(val: any): val is ILineSegment;
|
|
20
|
+
export declare class Point implements IPoint {
|
|
21
|
+
x: number;
|
|
22
|
+
y: number;
|
|
23
|
+
constructor(x: number, y: number);
|
|
24
|
+
}
|
|
25
|
+
export declare class Rect implements IRect {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
constructor(x: number, y: number, width: number, height: number);
|
|
31
|
+
get left(): number;
|
|
32
|
+
get right(): number;
|
|
33
|
+
get top(): number;
|
|
34
|
+
get bottom(): number;
|
|
35
|
+
}
|
|
36
|
+
export declare class LineSegment {
|
|
37
|
+
start: IPoint;
|
|
38
|
+
end: IPoint;
|
|
39
|
+
constructor(start: IPoint, end: IPoint);
|
|
40
|
+
}
|
|
41
|
+
export interface IRect {
|
|
42
|
+
x: number;
|
|
43
|
+
y: number;
|
|
44
|
+
width: number;
|
|
45
|
+
height: number;
|
|
46
|
+
}
|
|
47
|
+
export declare enum RectQuadrant {
|
|
48
|
+
Inner1 = "I1",
|
|
49
|
+
Inner2 = "I2",
|
|
50
|
+
Inner3 = "I3",
|
|
51
|
+
Inner4 = "I4",
|
|
52
|
+
Outer1 = "O1",
|
|
53
|
+
Outer2 = "O2",
|
|
54
|
+
Outer3 = "O3",
|
|
55
|
+
Outer4 = "O4"
|
|
56
|
+
}
|
|
57
|
+
export interface IPointToRectRelative {
|
|
58
|
+
quadrant: RectQuadrant;
|
|
59
|
+
distance: number;
|
|
60
|
+
}
|
|
61
|
+
export declare function isPointInRect(point: IPoint, rect: IRect, sensitive?: boolean): boolean;
|
|
62
|
+
export declare function isEqualRect(target: IRect, source: IRect): boolean;
|
|
63
|
+
export declare function getRectPoints(source: IRect): Point[];
|
|
64
|
+
export declare function isRectInRect(target: IRect, source: IRect): boolean;
|
|
65
|
+
export declare function isCrossRectInRect(target: IRect, source: IRect): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* 计算点在矩形的哪个象限
|
|
68
|
+
* @param point
|
|
69
|
+
* @param rect
|
|
70
|
+
*/
|
|
71
|
+
export declare function calcQuadrantOfPointToRect(point: IPoint, rect: IRect): RectQuadrant;
|
|
72
|
+
export declare function calcDistanceOfPointToRect(point: IPoint, rect: IRect): number;
|
|
73
|
+
export declare function calcDistancePointToEdge(point: IPoint, rect: IRect): number;
|
|
74
|
+
export declare function isNearAfter(point: IPoint, rect: IRect, inline?: boolean): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* 计算点鱼矩形的相对位置信息
|
|
77
|
+
* @param point
|
|
78
|
+
* @param rect
|
|
79
|
+
*/
|
|
80
|
+
export declare function calcRelativeOfPointToRect(point: IPoint, rect: IRect): IPointToRectRelative;
|
|
81
|
+
export declare function calcBoundingRect(rects: IRect[]): Rect;
|
|
82
|
+
export declare function calcRectByStartEndPoint(startPoint: IPoint, endPoint: IPoint, scrollX?: number, scrollY?: number): Rect;
|
|
83
|
+
export declare function calcEdgeLinesOfRect(rect: IRect): IRectEdgeLines;
|
|
84
|
+
export declare function calcRectOfAxisLineSegment(line: ILineSegment): Rect;
|
|
85
|
+
export declare function calcSpaceBlockOfRect(target: IRect, source: IRect, type?: string): {
|
|
86
|
+
type: string;
|
|
87
|
+
distance: number;
|
|
88
|
+
rect: Rect;
|
|
89
|
+
};
|
|
90
|
+
export declare function calcExtendsLineSegmentOfRect(targetRect: Rect, referRect: Rect): {
|
|
91
|
+
start: {
|
|
92
|
+
x: number;
|
|
93
|
+
y: number;
|
|
94
|
+
};
|
|
95
|
+
end: {
|
|
96
|
+
x: number;
|
|
97
|
+
y: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
export declare function calcOffsetOfSnapLineSegmentToEdge(line: ILineSegment, current: IRect): {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
};
|
|
104
|
+
export declare function calcDistanceOfSnapLineToEdges(line: ILineSegment, edges: IRectEdgeLines): number;
|
|
105
|
+
export declare function calcCombineSnapLineSegment(target: ILineSegment, source: ILineSegment): ILineSegment;
|
|
106
|
+
export declare function calcClosestEdges(line: ILineSegment, edges: IRectEdgeLines): [number, ILineSegment];
|