Skip to content

Commit

Permalink
fix drag-node x and y position
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanning.bzn committed Jul 19, 2019
1 parent 1699cfc commit 83ec443
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 31 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -99,7 +99,7 @@
"screenshot": "node ./bin/screenshot.js",
"start": "npm run dev",
"test": "torch --compile --renderer --opts test/mocha.opts --recursive ./test/unit",
"test-live": "torch --compile --interactive --watch --opts test/mocha.opts --recursive ./test/unit/behavior/brush-select-spec.js",
"test-live": "torch --compile --interactive --watch --opts test/mocha.opts --recursive ./test/unit/behavior/drag-node-spec.js",
"test-bugs": "torch --compile --renderer --recursive ./test/bugs",
"test-bugs-live": "torch --compile --interactive --watch --recursive ./test/bugs",
"test-all": "npm run test && npm run test-bugs",
Expand Down
29 changes: 1 addition & 28 deletions src/behavior/drag-node.js
Expand Up @@ -2,33 +2,6 @@ const { mix } = require('../util');
const { merge, isString } = require('lodash');
const { delegateStyle } = require('../global');
const body = document.body;
const gridRound = (x = 0) => {
const intStr = x.toFixed(0);
const tailNum = intStr.slice(-1);
const headNum = intStr.length > 1 ? intStr.slice(0, -1) : '';
let roundNum;
switch (tailNum) {
case '0':
case '1':
case '2':
case '3':
case '4':
roundNum = '0';
break;
case '5':
case '6':
case '7':
case '8':
case '9':
roundNum = '5';
break;
default:
roundNum = '0';
break;
}
const val = parseInt(`${headNum}${roundNum}`, 10);
return val;
};

module.exports = {
getDefaultCfg() {
Expand Down Expand Up @@ -176,7 +149,7 @@ module.exports = {
return;
}

const pos = { x: gridRound(x), y: gridRound(y) };
const pos = { x, y };

if (this.get('updateEdge')) {
this.graph.updateItem(item, pos);
Expand Down
4 changes: 2 additions & 2 deletions test/unit/behavior/drag-node-spec.js
Expand Up @@ -7,7 +7,7 @@ div.id = 'drag-spec';
document.body.appendChild(div);

describe('drag-node', () => {
it.only('drag node', () => {
it('drag node', () => {
const graph = new G6.Graph({
container: div,
width: 500,
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('drag-node', () => {
expect(matrix[7]).to.equal(70);
graph.destroy();
});
it.only('delegate drag node with edge', () => {
it('delegate drag node with edge', () => {
const graph = new G6.Graph({
container: div,
width: 500,
Expand Down

0 comments on commit 83ec443

Please sign in to comment.