how to implement mousemove after mousedown using js

133 views Asked by At

I need to implement a mouse over after mouse down , so that when user pressed and move the cells will be opened (minesweeper)

Here's my code !

case 2:
    {
        if ($(this).hasClass("open") || $(this).hasClass("bomb") || $(this).hasClass("close")) {
            var X_axis;
            var Y_axis;
            $('.close').mousemove(function (event2) {
                if ($(this).attr('row') != X_axis && $(this).attr('column') != Y_axis) {
                    var obj = $("[row='" + X_axis + "'][column='" + Y_axis + "']");
                    $(obj).addClass("close");
                }
                $(this).removeClass("close");
                X_axis = $(this).attr('row');
                Y_axis = $(this).attr('column');
            });
        }
    }
    break;


case 2 --> mean left mouse click 
1

There are 1 answers

0
M1M6 On BEST ANSWER

oh sorry , here's the solution

 if ($(this).attr('row') != X_axis || $(this).attr('column') != Y_axis)

use || not && , because the array 2d and maybe current cell x_axis equal to previous cell x_axis ....