diff --git a/package.json b/package.json index 12403d8..24bc638 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "react-dnd-html5-backend": "^11.1.3", "react-dom": "^16.12.0", "react-draggable": "^4.4.3", + "react-draggable-ball": "^0.1.0", "react-grid-layout": "^1.0.0", "react-hotkeys-hook": "^2.3.1", "react-text-loop": "^2.3.0", @@ -81,12 +82,12 @@ }, "license": "MIT", "devDependencies": { - "@types/qrcode.react": "^1.0.1", "@types/classnames": "^2.2.10", "@types/codemirror": "^0.0.98", "@types/events": "^3.0.0", "@types/file-saver": "^2.0.1", "@types/node": "^14.6.2", + "@types/qrcode.react": "^1.0.1", "@types/react-color": "^3.0.4", "@types/react-grid-layout": "^1.1.0", "@types/redux-logger": "^3.0.8", diff --git a/src/pages/editor/Container.tsx b/src/pages/editor/Container.tsx index 303821b..f08b90f 100644 --- a/src/pages/editor/Container.tsx +++ b/src/pages/editor/Container.tsx @@ -21,6 +21,7 @@ import schema from 'components/BasicShop/schema'; import { ActionCreators } from 'redux-undo'; import { StateWithHistory } from 'redux-undo'; import styles from './index.less'; +import { useGetBall } from 'react-draggable-ball'; const { TabPane } = Tabs; @@ -28,7 +29,6 @@ const Container = (props: { history?: any; location?: any; pstate?: any; dispatc const [scaleNum, setScale] = useState(1); const { pstate, dispatch } = props; - console.log(props); const pointData = pstate ? pstate.pointData : {}; const curPoint = pstate ? pstate.curPoint : {}; // 指定画布的id @@ -107,6 +107,12 @@ const Container = (props: { history?: any; location?: any; pstate?: any; dispatc return arr; }, []); + const [dragstate, setDragState] = useState({ x: 0, y: 0 }); + const [render] = useGetBall(setDragState, { + innerStyle: { top: '10px', left: '10px', cursor: 'pointer' }, + ratioSpeed: { x: 1.2, y: 1.2 }, + }); + return (