как использовать оба this.function в Vue.js - PullRequest
0 голосов
/ 08 марта 2019

Это моя функция handleMove, которая в основном работает как

<div class="container" @mousemove="handleMove"></div> 

Я хочу передать функцию Multiple, где я выделил жирным шрифтом в коде, проблема в том, что когда я делаю this.moveSelectedNode (diffX, diffY) другой this.moveSelectedDecision не работает

Проблема в том, что в this.moveSelectedDecision собираются одни узлы и наоборот для решений

когда я комментирую Один этот другой, это работает Отлично

Когда я комментирую один this.moveSelectedNode или this.moveSelectedDecision, другой работает нормально

  handleMove(e) {
              if (this.action.linking) {
                [this.mouse.x, this.mouse.y] = getMousePosition(this.$el, e);
                [this.draggingLink.mx, this.draggingLink.my] = [this.mouse.x, this.mouse.y];
              }
              if (this.action.dragging) {
                this.mouse.x = e.pageX || e.clientX + document.documentElement.scrollLeft
                this.mouse.y = e.pageY || e.clientY + document.documentElement.scrollTop
                let diffX = this.mouse.x - this.mouse.lastX;
                let diffY = this.mouse.y - this.mouse.lastY;

                this.mouse.lastX = this.mouse.x;
                this.mouse.lastY = this.mouse.y;
                this.moveSelectedNode(diffX, diffY);
                **this.moveSelectedDecision(diffX,diffY);**
                console.log('I am here');
              }
              if (this.action.scrolling) {
                [this.mouse.x, this.mouse.y] = getMousePosition(this.$el, e);
                let diffX = this.mouse.x - this.mouse.lastX;
                let diffY = this.mouse.y - this.mouse.lastY;

                this.mouse.lastX = this.mouse.x;
                this.mouse.lastY = this.mouse.y;

                this.scene.centerX += diffX;
                this.scene.centerY += diffY;

                // this.hasDragged = true
              }
            },

Это мои функции moveSelectedNode и moveSelectedDecision, которые я передаю в handleMove

 moveSelectedNode(dx, dy) {
          let index = this.scene.nodes.findIndex((item) => {
            return item.id === this.action.dragging
          })
          let left = this.scene.nodes[index].x + dx / this.scene.scale;
          let top = this.scene.nodes[index].y + dy / this.scene.scale;
          this.$set(this.scene.nodes, index, Object.assign(this.scene.nodes[index], {
            x: left,
            y: top,
          }));
        },
         moveSelectedDecision(dx, dy) {
          let index = this.scene.decisions.findIndex((item) => {
            return item.id === this.action.dragging
          })
          let left = this.scene.decisions[index].x + dx / this.scene.scale;
          let top = this.scene.decisions[index].y + dy / this.scene.scale;
          this.$set(this.scene.decisions, index, Object.assign(this.scene.decisions[index], {
            x: left,
            y: top,
          }));
        },
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...