update 0.11.4
This commit is contained in:
@@ -1,3 +1,11 @@
|
|||||||
|
|
||||||
|
## 0.11.4
|
||||||
|
|
||||||
|
修复参考线bug
|
||||||
|
|
||||||
|
优化拖拽算法
|
||||||
|
|
||||||
|
|
||||||
## 0.11.3
|
## 0.11.3
|
||||||
|
|
||||||
增加旋转回正功能。
|
增加旋转回正功能。
|
||||||
|
@@ -5,6 +5,9 @@ nav:
|
|||||||
title: change log
|
title: change log
|
||||||
order: 6
|
order: 6
|
||||||
---
|
---
|
||||||
|
## 0.11.4
|
||||||
|
Fix guide line bug
|
||||||
|
Optimized drag and drop algorithm
|
||||||
## 0.11.3
|
## 0.11.3
|
||||||
Add rotation return function.
|
Add rotation return function.
|
||||||
Optimize mouse style.
|
Optimize mouse style.
|
||||||
|
@@ -5,6 +5,14 @@ nav:
|
|||||||
title: 变更日志
|
title: 变更日志
|
||||||
order: 6
|
order: 6
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 0.11.4
|
||||||
|
|
||||||
|
修复参考线bug
|
||||||
|
|
||||||
|
优化拖拽算法
|
||||||
|
|
||||||
|
|
||||||
## 0.11.3
|
## 0.11.3
|
||||||
|
|
||||||
增加旋转回正功能。
|
增加旋转回正功能。
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "0.11.3",
|
"version": "0.11.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/dooringx-lib.esm.js",
|
"module": "dist/dooringx-lib.esm.js",
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\calcRender.ts
|
* @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\calcRender.ts
|
||||||
*/
|
*/
|
||||||
import { innerDragState } from '../innerDrag/state';
|
import { innerDragState } from '../innerDrag/state';
|
||||||
import { newMarklineDisplay } from './normalMode';
|
import { marklineDisplay, newMarklineDisplay } from './normalMode';
|
||||||
import { marklineConfig } from './marklineConfig';
|
import { marklineConfig } from './marklineConfig';
|
||||||
import UserConfig from '../../config';
|
import UserConfig from '../../config';
|
||||||
import { angleToRadian, binarySearchRemain, getContainer } from '../utils';
|
import { angleToRadian, binarySearchRemain, getContainer } from '../utils';
|
||||||
@@ -125,6 +125,13 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
|
|||||||
return a.right - b.right;
|
return a.right - b.right;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
// 划线的元素不应该冲突
|
||||||
|
// 当横向或者纵向已经吸附过,则后续不进行吸附,差值为0则划线。
|
||||||
|
// 未吸附过时的第一次划线会带吸附,后续按上述走
|
||||||
|
const dirty = {
|
||||||
|
dirtyX: false,
|
||||||
|
dirtyY: false,
|
||||||
|
};
|
||||||
const indexLeft = binarySearchRemain<RealStyleType>(
|
const indexLeft = binarySearchRemain<RealStyleType>(
|
||||||
realStyle.left,
|
realStyle.left,
|
||||||
marklineState.sortLeft,
|
marklineState.sortLeft,
|
||||||
@@ -132,7 +139,77 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
|
|||||||
marklineConfig.indent
|
marklineConfig.indent
|
||||||
);
|
);
|
||||||
if (indexLeft) {
|
if (indexLeft) {
|
||||||
newMarklineDisplay(realStyle, indexLeft, lines, focus);
|
marklineDisplay(realStyle, indexLeft[0], lines, focus, indexLeft[1], dirty, 'left');
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexLeftRight = binarySearchRemain<RealStyleType>(
|
||||||
|
realStyle.left,
|
||||||
|
marklineState.sortRight,
|
||||||
|
'right',
|
||||||
|
marklineConfig.indent
|
||||||
|
);
|
||||||
|
if (indexLeftRight) {
|
||||||
|
marklineDisplay(
|
||||||
|
realStyle,
|
||||||
|
indexLeftRight[0],
|
||||||
|
lines,
|
||||||
|
focus,
|
||||||
|
indexLeftRight[1],
|
||||||
|
dirty,
|
||||||
|
'l-r'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const indexRightLeft = binarySearchRemain<RealStyleType>(
|
||||||
|
realStyle.right,
|
||||||
|
marklineState.sortLeft,
|
||||||
|
'left',
|
||||||
|
marklineConfig.indent
|
||||||
|
);
|
||||||
|
if (indexRightLeft) {
|
||||||
|
marklineDisplay(
|
||||||
|
realStyle,
|
||||||
|
indexRightLeft[0],
|
||||||
|
lines,
|
||||||
|
focus,
|
||||||
|
indexRightLeft[1],
|
||||||
|
dirty,
|
||||||
|
'r-l'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const indexTopBottom = binarySearchRemain<RealStyleType>(
|
||||||
|
realStyle.top,
|
||||||
|
marklineState.sortBottom,
|
||||||
|
'bottom',
|
||||||
|
marklineConfig.indent
|
||||||
|
);
|
||||||
|
if (indexTopBottom) {
|
||||||
|
marklineDisplay(
|
||||||
|
realStyle,
|
||||||
|
indexTopBottom[0],
|
||||||
|
lines,
|
||||||
|
focus,
|
||||||
|
indexTopBottom[1],
|
||||||
|
dirty,
|
||||||
|
't-b'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const indexBottomTop = binarySearchRemain<RealStyleType>(
|
||||||
|
realStyle.bottom,
|
||||||
|
marklineState.sortTop,
|
||||||
|
'top',
|
||||||
|
marklineConfig.indent
|
||||||
|
);
|
||||||
|
if (indexBottomTop) {
|
||||||
|
marklineDisplay(
|
||||||
|
realStyle,
|
||||||
|
indexBottomTop[0],
|
||||||
|
lines,
|
||||||
|
focus,
|
||||||
|
indexBottomTop[1],
|
||||||
|
dirty,
|
||||||
|
'b-t'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
const indexTop = binarySearchRemain<RealStyleType>(
|
const indexTop = binarySearchRemain<RealStyleType>(
|
||||||
realStyle.top,
|
realStyle.top,
|
||||||
@@ -141,7 +218,7 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
|
|||||||
marklineConfig.indent
|
marklineConfig.indent
|
||||||
);
|
);
|
||||||
if (indexTop) {
|
if (indexTop) {
|
||||||
newMarklineDisplay(realStyle, indexTop, lines, focus);
|
marklineDisplay(realStyle, indexTop[0], lines, focus, indexTop[1], dirty, 'top');
|
||||||
}
|
}
|
||||||
const indexRight = binarySearchRemain<RealStyleType>(
|
const indexRight = binarySearchRemain<RealStyleType>(
|
||||||
realStyle.right,
|
realStyle.right,
|
||||||
@@ -150,7 +227,7 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
|
|||||||
marklineConfig.indent
|
marklineConfig.indent
|
||||||
);
|
);
|
||||||
if (indexRight) {
|
if (indexRight) {
|
||||||
newMarklineDisplay(realStyle, indexRight, lines, focus);
|
marklineDisplay(realStyle, indexRight[0], lines, focus, indexRight[1], dirty, 'right');
|
||||||
}
|
}
|
||||||
const indexBottom = binarySearchRemain<RealStyleType>(
|
const indexBottom = binarySearchRemain<RealStyleType>(
|
||||||
realStyle.bottom,
|
realStyle.bottom,
|
||||||
@@ -159,7 +236,7 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp
|
|||||||
marklineConfig.indent
|
marklineConfig.indent
|
||||||
);
|
);
|
||||||
if (indexBottom) {
|
if (indexBottom) {
|
||||||
newMarklineDisplay(realStyle, indexBottom, lines, focus);
|
marklineDisplay(realStyle, indexBottom[0], lines, focus, indexBottom[1], dirty, 'bottom');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < len; i++) {
|
for (let i = 0; i < len; i++) {
|
||||||
|
@@ -11,6 +11,134 @@ export interface RealStyle {
|
|||||||
bottom: number;
|
bottom: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @export 吸附间距之前已经算出,该函数直接做处理
|
||||||
|
* @param {RealStyle} focusStyle
|
||||||
|
* @param {RealStyle} unFocusStyle
|
||||||
|
* @param {LinesTypes} lines
|
||||||
|
* @param {IBlockType} focus
|
||||||
|
* @param {number} diff 绝对值
|
||||||
|
* @param {('left' | 'top' | 'bottom' | 'right' | 't-b' | 'b-t' | 'l-r' | 'r-l')} direction
|
||||||
|
*/
|
||||||
|
export function marklineDisplay(
|
||||||
|
focusStyle: RealStyle,
|
||||||
|
unFocusStyle: RealStyle,
|
||||||
|
lines: LinesTypes,
|
||||||
|
focus: IBlockType,
|
||||||
|
diff: number,
|
||||||
|
dirty: { dirtyX: boolean; dirtyY: boolean },
|
||||||
|
direction: 'left' | 'top' | 'bottom' | 'right' | 't-b' | 'b-t' | 'l-r' | 'r-l'
|
||||||
|
) {
|
||||||
|
const { top, height, left, width } = focusStyle;
|
||||||
|
let { dirtyX, dirtyY } = dirty;
|
||||||
|
const { top: t, height: h, left: l, width: w } = unFocusStyle;
|
||||||
|
let diffY = 0;
|
||||||
|
let diffX = 0;
|
||||||
|
switch (direction) {
|
||||||
|
case 'left':
|
||||||
|
if (dirtyY) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.y.push(l);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.y.push(l);
|
||||||
|
diffX = l - left;
|
||||||
|
dirtyY = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'right':
|
||||||
|
if (dirtyY) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.y.push(l + w);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.y.push(l + w);
|
||||||
|
diffX = l + w - left - width;
|
||||||
|
dirtyY = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'l-r':
|
||||||
|
if (dirtyY) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.y.push(l + w);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.y.push(l + w);
|
||||||
|
diffX = l + w - left;
|
||||||
|
dirtyY = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'r-l':
|
||||||
|
if (dirtyY) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.y.push(l);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.y.push(l);
|
||||||
|
diffX = l - (left + width);
|
||||||
|
dirtyY = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'top':
|
||||||
|
if (dirtyX) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.x.push(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.x.push(t);
|
||||||
|
diffY = t - top;
|
||||||
|
dirtyX = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'bottom':
|
||||||
|
if (dirtyX) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.x.push(t + h);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.x.push(t + h);
|
||||||
|
diffY = (t + h - top - height) / 2;
|
||||||
|
dirtyX = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 't-b':
|
||||||
|
if (dirtyX) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.x.push(t + h);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.x.push(t + h);
|
||||||
|
diffY = (t + h - top) / 2;
|
||||||
|
dirtyX = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'b-t':
|
||||||
|
if (dirtyX) {
|
||||||
|
if (diff === 0) {
|
||||||
|
lines.x.push(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lines.x.push(t);
|
||||||
|
diffY = t - (top + height);
|
||||||
|
dirtyX = true;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
focus.top = Math.round(focus.top + diffY);
|
||||||
|
focus.left = Math.round(focus.left + diffX);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 第一次运算时需要
|
||||||
|
* @export
|
||||||
|
* @param {RealStyle} focusStyle
|
||||||
|
* @param {RealStyle} unFocusStyle
|
||||||
|
* @param {LinesTypes} lines
|
||||||
|
* @param {IBlockType} focus
|
||||||
|
*/
|
||||||
export function newMarklineDisplay(
|
export function newMarklineDisplay(
|
||||||
focusStyle: RealStyle,
|
focusStyle: RealStyle,
|
||||||
unFocusStyle: RealStyle,
|
unFocusStyle: RealStyle,
|
||||||
@@ -116,6 +244,10 @@ export function newMarklineDisplay(
|
|||||||
focus.left = Math.round(focus.left + diffX);
|
focus.left = Math.round(focus.left + diffX);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
export function switchMarklineDisplay(
|
export function switchMarklineDisplay(
|
||||||
l: number,
|
l: number,
|
||||||
t: number,
|
t: number,
|
||||||
@@ -303,6 +435,9 @@ export function switchMarklineDisplay(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo 暂时无效
|
||||||
|
*/
|
||||||
export function switchMarklineResizeDisplay(
|
export function switchMarklineResizeDisplay(
|
||||||
l: number,
|
l: number,
|
||||||
t: number,
|
t: number,
|
||||||
|
@@ -316,14 +316,14 @@ export function binarySearchRemain<T extends Record<string, number>>(
|
|||||||
arr: Array<T>,
|
arr: Array<T>,
|
||||||
attribute: keyof T,
|
attribute: keyof T,
|
||||||
indent: number
|
indent: number
|
||||||
) {
|
): null | [T, number] {
|
||||||
let start = 0;
|
let start = 0;
|
||||||
let end = arr.length - 1;
|
let end = arr.length - 1;
|
||||||
|
|
||||||
while (start <= end) {
|
while (start <= end) {
|
||||||
var mid = parseInt(start + (end - start) / 2 + '');
|
let mid = parseInt(start + (end - start) / 2 + '');
|
||||||
if (target === arr[mid][attribute] || Math.abs(target - arr[mid][attribute]) < indent) {
|
if (target === arr[mid][attribute] || Math.abs(target - arr[mid][attribute]) < indent) {
|
||||||
return arr[mid];
|
return [arr[mid], Math.abs(target - arr[mid][attribute])];
|
||||||
} else if (target > arr[mid][attribute]) {
|
} else if (target > arr[mid][attribute]) {
|
||||||
start = mid + 1;
|
start = mid + 1;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "dooringx-plugin-template",
|
"name": "dooringx-plugin-template",
|
||||||
"version": "0.11.3",
|
"version": "0.11.4",
|
||||||
"description": "> TODO: description",
|
"description": "> TODO: description",
|
||||||
"author": "yehuozhili <673632758@qq.com>",
|
"author": "yehuozhili <673632758@qq.com>",
|
||||||
"homepage": "https://github.com/H5-Dooring/dooringx#readme",
|
"homepage": "https://github.com/H5-Dooring/dooringx#readme",
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
"@rollup/plugin-node-resolve": "^13.0.4",
|
"@rollup/plugin-node-resolve": "^13.0.4",
|
||||||
"@rollup/plugin-url": "^6.1.0",
|
"@rollup/plugin-url": "^6.1.0",
|
||||||
"@svgr/rollup": "^5.5.0",
|
"@svgr/rollup": "^5.5.0",
|
||||||
"dooringx-lib": "^0.11.3",
|
"dooringx-lib": "^0.11.4",
|
||||||
"postcss": "^8.3.6",
|
"postcss": "^8.3.6",
|
||||||
"rollup-plugin-peer-deps-external": "^2.2.4",
|
"rollup-plugin-peer-deps-external": "^2.2.4",
|
||||||
"rollup-plugin-postcss": "^4.0.1",
|
"rollup-plugin-postcss": "^4.0.1",
|
||||||
|
Reference in New Issue
Block a user