Skip to content

Commit

Permalink
refactor: Split Ables
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed Aug 11, 2019
1 parent 7340549 commit 1b4558a
Show file tree
Hide file tree
Showing 27 changed files with 1,468 additions and 1,269 deletions.
1 change: 1 addition & 0 deletions packages/react-moveable/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default builder([
...defaultOptions,
input: "src/react-moveable/index.ts",
output: "./dist/moveable.esm.js",
visualizer: true,
format: "es",
},
{
Expand Down
15 changes: 13 additions & 2 deletions packages/react-moveable/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,24 @@ class App extends React.Component {
</div>
);
}
public onCLickOuside = (e: any) => {

}
public onClickInside = (e: any) => {
const target = e.target;

}
public onClick = (e: any) => {
const target = e.target;

const id = target.getAttribute("data-target");
e.preventDefault();

if (!id) {
const clientX = e.clientX;
const clientY = e.clientY;

console.log(this.moveable.isInside(clientX, clientY));
if (!id || this.state.target && this.moveable.isInside(clientX, clientY)) {
return;
}
const items = this.items;
Expand All @@ -143,7 +154,7 @@ class App extends React.Component {
target: e.target,
item: items[id],
}, () => {
this.moveable.dragstart(nativeEvent);
this.moveable.dragStart(nativeEvent);
});
}
}
Expand Down
101 changes: 0 additions & 101 deletions packages/react-moveable/src/react-moveable/Draggable.ts

This file was deleted.

28 changes: 0 additions & 28 deletions packages/react-moveable/src/react-moveable/DraggableDragger.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Moveable from "./Moveable";
import { invert, caculate, minus, sum, convertPositionMatrix } from "./matrix";
import MoveableManager from "./MoveableManager";

export function setDragStart(moveable: Moveable, { datas }: any) {
export function setDragStart(moveable: MoveableManager<any>, { datas }: any) {
const {
matrix,
beforeMatrix,
Expand All @@ -12,14 +12,15 @@ export function setDragStart(moveable: Moveable, { datas }: any) {
} = moveable.state;

const n = is3d ? 4 : 3;

datas.is3d = is3d;
datas.matrix = matrix;
datas.inverseMatrix = invert(matrix, n);
datas.beforeMatrix = beforeMatrix;
datas.inverseBeforeMatrix = invert(beforeMatrix, n);
datas.absoluteOrigin = convertPositionMatrix(sum([left, top], origin), n);
datas.startDragBeforeDist = caculate(datas.inverseBeforeMatrix, datas.absoluteOrigin, is3d ? 4 : 3);
datas.startDragDist = caculate(datas.inverseMatrix, datas.absoluteOrigin, is3d ? 4 : 3);
datas.startDragBeforeDist = caculate(datas.inverseBeforeMatrix, datas.absoluteOrigin, n);
datas.startDragDist = caculate(datas.inverseMatrix, datas.absoluteOrigin, n);
}
export function getDragDist({ datas, distX, distY }: any, isBefore?: boolean) {
const {
Expand Down
Loading

0 comments on commit 1b4558a

Please sign in to comment.