JSFiddle - React, Tailwind, and code Playground

by kougiland

HTML

<div id="main">
    <div class="statusbar">
        <p class="position"></p>
    </div>
</div>

CSS

div { border: solid 1px red; padding: 100px; }

JavaScript

function handleMouseDown(e, sbar){
    if (e.button == 0){
        console.log(sbar); //firebug
        $(sbar).bind('mousemove', function(event){
            handleMouseMove(event, sbar);
        });
    }
}

function handleMouseUp(e, sbar){
    $(sbar).unbind('mousemove');       
}

function handleMouseMove(e, sbar){
    // not sure it this will work yet, but unimportant
    $(".position").html(e.pageX);
}

$(document).ready(function (){

    var statusbar = $(".statusbar");

    statusbar.mousedown(function(event){
        handleMouseDown(event, this);
    });

    statusbar.mouseup(function(event){
        handleMouseUp(event, this);
    });

});