update 0.7.7

This commit is contained in:
hufeixiong
2021-08-04 14:20:50 +08:00
parent e26d4ee2ab
commit 6323b9419f
7 changed files with 42 additions and 16 deletions

View File

@@ -1,5 +1,10 @@
## changelog ## changelog
## 0.7.7
优化画布拖拽逻辑,更平滑移动。
## 0.7.6 ## 0.7.6
右侧自定义rightGlobalCustom类型变更为函数传入config 右侧自定义rightGlobalCustom类型变更为函数传入config

View File

@@ -151,6 +151,8 @@ MIT
## Todo ## Todo
动画部分重构
函数部分重构 函数部分重构

View File

@@ -4,6 +4,11 @@ order: 1
--- ---
## changelog ## changelog
## 0.7.7
优化画布拖拽逻辑,更平滑移动。
## 0.7.6 ## 0.7.6
右侧自定义rightGlobalCustom类型变更为函数传入config 右侧自定义rightGlobalCustom类型变更为函数传入config

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-07-17 10:12:11 * @Date: 2021-07-17 10:12:11
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-20 17:08:37 * @LastEditTime: 2021-08-03 14:06:12
* @FilePath: \dooringx\packages\dooringx-example\src\pages\iframeTest.tsx * @FilePath: \dooringx\packages\dooringx-example\src\pages\iframeTest.tsx
*/ */
@@ -34,7 +34,7 @@ export default function IndexPage() {
useIframeHook(`${location.origin}/container`, config); useIframeHook(`${location.origin}/container`, config);
return ( return (
<div {...innerContainerDragUp(config, true)}> <div {...innerContainerDragUp(config)}>
<div style={{ height: HeaderHeight }}> <div style={{ height: HeaderHeight }}>
head head
<button <button

View File

@@ -1,5 +1,5 @@
{ {
"version": "0.7.6", "version": "0.7.7",
"license": "MIT", "license": "MIT",
"main": "dist/index.js", "main": "dist/index.js",
"module": "dist/dooringx-lib.esm.js", "module": "dist/dooringx-lib.esm.js",

View File

@@ -50,8 +50,8 @@ export const innerDrag = function (
innerDragState.startX = Math.round(e.clientX); innerDragState.startX = Math.round(e.clientX);
innerDragState.startY = Math.round(e.clientY); innerDragState.startY = Math.round(e.clientY);
innerDragState.item = item; innerDragState.item = item;
// innerDragState.itemX = item.left; 会导致框选后移动问题 innerDragState.itemX = item.left; // 会导致框选后移动问题 进行分类判断 否则体验不是很好
// innerDragState.itemY = item.top; innerDragState.itemY = item.top;
innerDragState.isDrag = true; innerDragState.isDrag = true;
innerDragState.ref = ref; innerDragState.ref = ref;
innerDragState.current = store.getIndex(); innerDragState.current = store.getIndex();
@@ -76,6 +76,8 @@ export const innerContainerDrag = function (config: UserConfig) {
if (current?.position === 'static') { if (current?.position === 'static') {
return; return;
} }
const focus = config.getFocusState();
const isMulti = focus.blocks.length > 1;
let { clientX: moveX, clientY: moveY } = e; let { clientX: moveX, clientY: moveY } = e;
const { startX, startY } = innerDragState; const { startX, startY } = innerDragState;
const scale = scaleState.value; const scale = scaleState.value;
@@ -87,24 +89,36 @@ export const innerContainerDrag = function (config: UserConfig) {
lastblock = innerDragState.item; lastblock = innerDragState.item;
newblock = cloneblock.map((v) => { newblock = cloneblock.map((v) => {
if (v.focus && v.position !== 'static') { if (v.focus && v.position !== 'static') {
if (isMulti) {
v.left = Math.round(v.left + durX); v.left = Math.round(v.left + durX);
v.top = Math.round(v.top + durY); v.top = Math.round(v.top + durY);
} else {
v.left = Math.round(innerDragState.itemX + durX);
v.top = Math.round(innerDragState.itemY + durY);
}
} }
return v; return v;
}); });
} else { } else {
newblock = store.getData().block.map((v) => { newblock = store.getData().block.map((v) => {
if (v.focus && v.position !== 'static') { if (v.focus && v.position !== 'static') {
if (isMulti) {
v.left = Math.round(v.left + durX); v.left = Math.round(v.left + durX);
v.top = Math.round(v.top + durY); v.top = Math.round(v.top + durY);
} else {
v.left = Math.round(innerDragState.itemX + durX);
v.top = Math.round(innerDragState.itemY + durY);
}
} }
return v; return v;
}); });
} }
store.setData({ ...store.getData(), block: newblock }); store.setData({ ...store.getData(), block: newblock });
if (isMulti) {
innerDragState.startX = moveX; innerDragState.startX = moveX;
innerDragState.startY = moveY; innerDragState.startY = moveY;
} }
}
resizerMouseMove(e, config); resizerMouseMove(e, config);
rotateMouseMove(e, config); rotateMouseMove(e, config);
if (selectData.selectDiv) { if (selectData.selectDiv) {

View File

@@ -2,7 +2,7 @@
* @Author: yehuozhili * @Author: yehuozhili
* @Date: 2021-03-14 12:09:11 * @Date: 2021-03-14 12:09:11
* @LastEditors: yehuozhili * @LastEditors: yehuozhili
* @LastEditTime: 2021-07-29 10:48:29 * @LastEditTime: 2021-08-04 11:39:02
* @FilePath: \dooringx\packages\dooringx-lib\src\core\innerDrag\state.ts * @FilePath: \dooringx\packages\dooringx-lib\src\core\innerDrag\state.ts
*/ */
import { RefObject } from 'react'; import { RefObject } from 'react';
@@ -17,8 +17,8 @@ export interface innerDragStateType {
ref: RefObject<HTMLDivElement> | null; ref: RefObject<HTMLDivElement> | null;
current: number; current: number;
lastClick: null | IBlockType; lastClick: null | IBlockType;
// itemX: number; itemX: number;
// itemY: number; itemY: number;
} }
export const innerDragState: innerDragStateType = { export const innerDragState: innerDragStateType = {
@@ -29,6 +29,6 @@ export const innerDragState: innerDragStateType = {
ref: null, ref: null,
current: 0, current: 0,
lastClick: null, lastClick: null,
// itemX: 0, itemX: 0,
// itemY: 0, itemY: 0,
}; };