发生这种情况是因为
move()仅当将块从 Gray区域之外移动时才调用your,但是
draw()所有鼠标移动都调用了your 。
currentBox选择并移动位置时,您需要更新位置。
draw() { const movingBlockIndex = (this.dropzone1.indexOf(this.currentBox)); if (movingBlockIndex > -1) { this.will_draw = false; const { width, height } = this.parentparent.nativeElement.getBoundingClientRect(); const perc_x = this.mouse.x / width * 100; const perc_y = this.mouse.y / height * 100; // -5 to center (elem has its width set to 10%) // console.log('left', (perc_x - 5) + '%'); this.left = perc_x - 5; this.topLeft = [] this.topLeft.push(this.left); // -5 to center (elem has its height set to 10%) // console.log('top', (perc_y - 5) + '%'); this.top = perc_y - 5; this.topLeft.push(this.top) this.dropzone1[movingBlockIndex].pos[0] = (perc_x - 5); this.dropzone1[movingBlockIndex].pos[1] = (perc_y - 5); } }


