Skip to content

Commit

Permalink
fix: skip beforeEvent set to lastEvent #654
Browse files Browse the repository at this point in the history
  • Loading branch information
daybrush committed May 1, 2022
1 parent a8bcb54 commit 5ab31c7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/react-moveable/src/react-moveable/ables/Resizable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ export default {
setSize(size: number[]) {
[boundingWidth, boundingHeight] = size;
},
}));
}, true));

let fixedPosition = dragClient;

Expand Down Expand Up @@ -537,7 +537,7 @@ export default {
triggerEvent(moveable, "onBeforeResizeGroup", fillParams<OnBeforeResizeGroup>(moveable, e, {
...parentEvent,
targets: moveable.props.targets!,
}));
}, true));
});


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default {
beforeDist = dist;
absoluteDist = dist;
},
}));
}, true));
[
beforeDelta,
beforeDist,
Expand Down Expand Up @@ -592,7 +592,7 @@ export default {
triggerEvent(moveable, "onBeforeRotateGroup", fillParams<OnBeforeRotateGroup>(moveable, e, {
...parentEvent,
targets: moveable.props.targets!,
}));
}, true));
});
const params = this.dragControl(moveable, e);

Expand Down
4 changes: 2 additions & 2 deletions packages/react-moveable/src/react-moveable/ables/Scalable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export default {
setScale(nextScale: number[]) {
scale = nextScale;
},
}));
}, true));

const dist = [scale[0] / startValue[0], scale[1] / startValue[1]];
let fixedPosition = dragClient;
Expand Down Expand Up @@ -442,7 +442,7 @@ export default {
triggerEvent(moveable, "onBeforeScaleGroup", fillParams<OnBeforeScaleGroup>(moveable, e, {
...parentEvent,
targets: moveable.props.targets!,
}));
}, true));
});

const params = this.dragControl(moveable, e);
Expand Down
7 changes: 4 additions & 3 deletions packages/react-moveable/src/react-moveable/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1152,6 +1152,7 @@ export function fillParams<T extends IObject<any>>(
moveable: any,
e: any,
params: ExcludeParams<T>,
isBeforeEvent?: boolean,
): T {
const datas = e.datas;

Expand All @@ -1169,10 +1170,10 @@ export function fillParams<T extends IObject<any>>(
datas: datas.datas,
} as any;

if (datas.isStartEvent) {
datas.lastEvent = nextParams;
} else {
if (!datas.isStartEvent) {
datas.isStartEvent = true;
} else if (!isBeforeEvent) {
datas.lastEvent = nextParams;
}
return nextParams;
}
Expand Down

0 comments on commit 5ab31c7

Please sign in to comment.