diff --git a/CHANGELOG.md b/CHANGELOG.md index 59bd550..cfe19be 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.11.7 + +取消多选吸附功能。 ## 0.11.6 取消第一次点击鼠标的吸附。 diff --git a/packages/dooringx-dumi-doc/docs/ChangeLog/index.en.md b/packages/dooringx-dumi-doc/docs/ChangeLog/index.en.md index 565df1c..2565ea5 100644 --- a/packages/dooringx-dumi-doc/docs/ChangeLog/index.en.md +++ b/packages/dooringx-dumi-doc/docs/ChangeLog/index.en.md @@ -5,6 +5,8 @@ nav: title: change log order: 6 --- +## 0.11.7 +Cancel the multi selection adsorption function. ## 0.11.6 Cancel the first mouse click. Modify the selected color of timeline. diff --git a/packages/dooringx-dumi-doc/docs/ChangeLog/index.md b/packages/dooringx-dumi-doc/docs/ChangeLog/index.md index 211526d..0dec290 100644 --- a/packages/dooringx-dumi-doc/docs/ChangeLog/index.md +++ b/packages/dooringx-dumi-doc/docs/ChangeLog/index.md @@ -5,6 +5,9 @@ nav: title: 变更日志 order: 6 --- +## 0.11.7 + +取消多选吸附功能。 ## 0.11.6 取消第一次点击鼠标的吸附。 diff --git a/packages/dooringx-lib/package.json b/packages/dooringx-lib/package.json index c0217fe..79019e4 100644 --- a/packages/dooringx-lib/package.json +++ b/packages/dooringx-lib/package.json @@ -1,5 +1,5 @@ { - "version": "0.11.6", + "version": "0.11.7", "license": "MIT", "main": "dist/index.js", "module": "dist/dooringx-lib.esm.js", diff --git a/packages/dooringx-lib/src/core/markline/calcRender.ts b/packages/dooringx-lib/src/core/markline/calcRender.ts index 46f731f..15546d7 100644 --- a/packages/dooringx-lib/src/core/markline/calcRender.ts +++ b/packages/dooringx-lib/src/core/markline/calcRender.ts @@ -2,7 +2,7 @@ * @Author: yehuozhili * @Date: 2021-03-14 04:29:09 * @LastEditors: yehuozhili - * @LastEditTime: 2021-12-31 00:25:43 + * @LastEditTime: 2022-01-12 09:15:44 * @FilePath: \dooringx\packages\dooringx-lib\src\core\markline\calcRender.ts */ import { innerDragState } from '../innerDrag/state'; @@ -105,137 +105,140 @@ export function marklineCalRender(config: UserConfig, iframe: boolean): LinesTyp // 只要cache里有东西,说明有缓存 if (marklineState.cache) { - if (!marklineState.sortLeft) { - marklineState.sortLeft = Object.values(marklineState.cache).sort((a, b) => { - return a.left - b.left; - }); - } - if (!marklineState.sortTop) { - marklineState.sortTop = Object.values(marklineState.cache).sort((a, b) => { - return a.top - b.top; - }); - } - if (!marklineState.sortBottom) { - marklineState.sortBottom = Object.values(marklineState.cache).sort((a, b) => { - return a.bottom - b.bottom; - }); - } - if (!marklineState.sortRight) { - marklineState.sortRight = Object.values(marklineState.cache).sort((a, b) => { - return a.right - b.right; - }); - } - // 划线的元素不应该冲突 - // 当横向或者纵向已经吸附过,则后续不进行吸附,差值为0则划线。 - // 未吸附过时的第一次划线会带吸附,后续按上述走 - const dirty = { - dirtyX: false, - dirtyY: false, - }; - const indexLeft = binarySearchRemain( - realStyle.left, - marklineState.sortLeft, - 'left', - marklineConfig.indent - ); - if (indexLeft) { - marklineDisplay(realStyle, indexLeft[0], lines, focus, indexLeft[1], dirty, 'left'); - } - - const indexLeftRight = binarySearchRemain( - realStyle.left, - marklineState.sortRight, - 'right', - marklineConfig.indent - ); - if (indexLeftRight) { - marklineDisplay( - realStyle, - indexLeftRight[0], - lines, - focus, - indexLeftRight[1], - dirty, - 'l-r' + const focusItem = config.getFocusState(); + const isMulti = focusItem.blocks.length > 1; + if (!isMulti) { + if (!marklineState.sortLeft) { + marklineState.sortLeft = Object.values(marklineState.cache).sort((a, b) => { + return a.left - b.left; + }); + } + if (!marklineState.sortTop) { + marklineState.sortTop = Object.values(marklineState.cache).sort((a, b) => { + return a.top - b.top; + }); + } + if (!marklineState.sortBottom) { + marklineState.sortBottom = Object.values(marklineState.cache).sort((a, b) => { + return a.bottom - b.bottom; + }); + } + if (!marklineState.sortRight) { + marklineState.sortRight = Object.values(marklineState.cache).sort((a, b) => { + return a.right - b.right; + }); + } + // 划线的元素不应该冲突 + // 当横向或者纵向已经吸附过,则后续不进行吸附,差值为0则划线。 + // 未吸附过时的第一次划线会带吸附,后续按上述走 + const dirty = { + dirtyX: false, + dirtyY: false, + }; + const indexLeft = binarySearchRemain( + realStyle.left, + marklineState.sortLeft, + 'left', + marklineConfig.indent ); - } - const indexRightLeft = binarySearchRemain( - realStyle.right, - marklineState.sortLeft, - 'left', - marklineConfig.indent - ); - if (indexRightLeft) { - marklineDisplay( - realStyle, - indexRightLeft[0], - lines, - focus, - indexRightLeft[1], - dirty, - 'r-l' + if (indexLeft) { + marklineDisplay(realStyle, indexLeft[0], lines, focus, indexLeft[1], dirty, 'left'); + } + const indexLeftRight = binarySearchRemain( + realStyle.left, + marklineState.sortRight, + 'right', + marklineConfig.indent ); - } - const indexTopBottom = binarySearchRemain( - realStyle.top, - marklineState.sortBottom, - 'bottom', - marklineConfig.indent - ); - if (indexTopBottom) { - marklineDisplay( - realStyle, - indexTopBottom[0], - lines, - focus, - indexTopBottom[1], - dirty, - 't-b' + if (indexLeftRight) { + marklineDisplay( + realStyle, + indexLeftRight[0], + lines, + focus, + indexLeftRight[1], + dirty, + 'l-r' + ); + } + const indexRightLeft = binarySearchRemain( + realStyle.right, + marklineState.sortLeft, + 'left', + marklineConfig.indent ); - } - const indexBottomTop = binarySearchRemain( - realStyle.bottom, - marklineState.sortTop, - 'top', - marklineConfig.indent - ); - if (indexBottomTop) { - marklineDisplay( - realStyle, - indexBottomTop[0], - lines, - focus, - indexBottomTop[1], - dirty, - 'b-t' + if (indexRightLeft) { + marklineDisplay( + realStyle, + indexRightLeft[0], + lines, + focus, + indexRightLeft[1], + dirty, + 'r-l' + ); + } + const indexTopBottom = binarySearchRemain( + realStyle.top, + marklineState.sortBottom, + 'bottom', + marklineConfig.indent ); - } - const indexTop = binarySearchRemain( - realStyle.top, - marklineState.sortTop, - 'top', - marklineConfig.indent - ); - if (indexTop) { - marklineDisplay(realStyle, indexTop[0], lines, focus, indexTop[1], dirty, 'top'); - } - const indexRight = binarySearchRemain( - realStyle.right, - marklineState.sortRight, - 'right', - marklineConfig.indent - ); - if (indexRight) { - marklineDisplay(realStyle, indexRight[0], lines, focus, indexRight[1], dirty, 'right'); - } - const indexBottom = binarySearchRemain( - realStyle.bottom, - marklineState.sortBottom, - 'bottom', - marklineConfig.indent - ); - if (indexBottom) { - marklineDisplay(realStyle, indexBottom[0], lines, focus, indexBottom[1], dirty, 'bottom'); + if (indexTopBottom) { + marklineDisplay( + realStyle, + indexTopBottom[0], + lines, + focus, + indexTopBottom[1], + dirty, + 't-b' + ); + } + const indexBottomTop = binarySearchRemain( + realStyle.bottom, + marklineState.sortTop, + 'top', + marklineConfig.indent + ); + if (indexBottomTop) { + marklineDisplay( + realStyle, + indexBottomTop[0], + lines, + focus, + indexBottomTop[1], + dirty, + 'b-t' + ); + } + const indexTop = binarySearchRemain( + realStyle.top, + marklineState.sortTop, + 'top', + marklineConfig.indent + ); + if (indexTop) { + marklineDisplay(realStyle, indexTop[0], lines, focus, indexTop[1], dirty, 'top'); + } + const indexRight = binarySearchRemain( + realStyle.right, + marklineState.sortRight, + 'right', + marklineConfig.indent + ); + if (indexRight) { + marklineDisplay(realStyle, indexRight[0], lines, focus, indexRight[1], dirty, 'right'); + } + const indexBottom = binarySearchRemain( + realStyle.bottom, + marklineState.sortBottom, + 'bottom', + marklineConfig.indent + ); + if (indexBottom) { + marklineDisplay(realStyle, indexBottom[0], lines, focus, indexBottom[1], dirty, 'bottom'); + } } } else { for (let i = 0; i < len; i++) { diff --git a/packages/dooringx-plugin-template/package.json b/packages/dooringx-plugin-template/package.json index ccb2cd2..23f5f1e 100644 --- a/packages/dooringx-plugin-template/package.json +++ b/packages/dooringx-plugin-template/package.json @@ -1,6 +1,6 @@ { "name": "dooringx-plugin-template", - "version": "0.11.6", + "version": "0.11.7", "description": "> TODO: description", "author": "yehuozhili <673632758@qq.com>", "homepage": "https://github.com/H5-Dooring/dooringx#readme", diff --git a/packages/dooringx-plugin-template/template/template.json b/packages/dooringx-plugin-template/template/template.json index 26de48e..fae3e46 100644 --- a/packages/dooringx-plugin-template/template/template.json +++ b/packages/dooringx-plugin-template/template/template.json @@ -40,7 +40,7 @@ "@rollup/plugin-node-resolve": "^13.0.4", "@rollup/plugin-url": "^6.1.0", "@svgr/rollup": "^5.5.0", - "dooringx-lib": "^0.11.6", + "dooringx-lib": "^0.11.7", "postcss": "^8.3.6", "rollup-plugin-peer-deps-external": "^2.2.4", "rollup-plugin-postcss": "^4.0.1",