javascript - How to implement multiselect in Vue -


i trying mimic spreadsheet feature can select multiple table cells pressing shift + mouseover, , having trouble getting select nearby cells fall within start , end range of selection. example, 3x3 grid, cell 0,0 start cell, when mouseover 0,1, , 1,1 1,0 should selected falls within range. here logic have far, selects cells mouse passes on (non of adjacent cells selected).

here code:

 selectcell (row, col) {   this.coors.push({x: row, y: col})   let len = this.coors.length - 1   this.start = {x: this.coors[0].x, y: this.coors[0].y}   this.end = {x: this.coors[len].x, y: this.coors[len].y}   this.grid[row].splice(col, 1, 2)   this.iterateovergrid(2) }, iterateovergrid (col) {   (let = this.start.x; <= this.end.x; i++) {     this.grid[i].splice(this.end.y, 1, col)     (let j = this.start.y; j <= this.end.y; j++) {       this.grid[i].splice(this.end.y, 1, col)     }   } }, 

start holds x , y position of first cell selected; end holds x , y position of last cell selected. idea iterate on each row , column in grid (which attempting in iterateovergrid() method) , assign value of 2 each cell falls within start end parameter. how can achieve this?


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -