Skip to content

Commit

Permalink
✨ add restartForceOnDrag flag in options
Browse files Browse the repository at this point in the history
  • Loading branch information
zxc0328 committed Jan 7, 2020
1 parent 23d3e46 commit fb70672
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/graphin/src/events/drag-with-force.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { G6Event } from '../types';
const dragWithForce = (graphin: Graphin) => {
const { graph, g6Options } = graphin;

const { autoFollowWithForce = true, autoPinWithForce = true } = g6Options!;
const { autoFollowWithForce = true, autoPinWithForce = true, restartForceOnDrag = true } = g6Options!;

/** 拖拽Force节点:start */
graph!.on('node:dragstart', () => {
Expand All @@ -15,7 +15,7 @@ const dragWithForce = (graphin: Graphin) => {

/** 拖拽结束 */
graph!.on('node:dragend', (e: G6Event) => {
if (graphin.state.forceSimulation && autoFollowWithForce) {
if (graphin.state.forceSimulation && autoFollowWithForce && restartForceOnDrag) {
const nodeModel = e.item.get('model');
nodeModel.x = e.x;
nodeModel.y = e.y;
Expand Down
1 change: 1 addition & 0 deletions packages/graphin/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export interface ExtendedGraphOptions extends GraphOptions {
keyShapeZoom?: number;
autoFollowWithForce?: boolean;
autoPinWithForce?: boolean;
restartForceOnDrag?: boolean;
[key: string]: any; // eslint-disable-line
}

Expand Down

0 comments on commit fb70672

Please sign in to comment.