JSFiddle - React, Tailwind, and code Playground

by Cyril Cherian

HTML

<div class="container"></div>

CSS

.container {
    height:200px;
    width:200px;
    background-color:#1abc9c;
}

JavaScript

$('.container').mousedown(function(e1){
    var mx = e1.pageX;//register the mouse down position
    
    $(this).mousemove(function(e2){
        
        if (e2.pageX > mx){ //right w.r.t mouse down position
            console.log("Moved Right");
        } else {
            console.log("Moved Left")
        }
    });
});     
  $('.container').mouseup(function(){
    $(this).unbind("mousemove");
});