JSFiddle - React, Tailwind, and code Playground

HTML

<div id="box"></div>
<div id="scrollStatus"></div>

CSS

#box{
    width:150px;
    height:150px;
    background-color:beige;
    border:1px solid black;
    cursor: pointer;
}
div#scrollStatus {
    width:150px;
    height:20px;
    border:1px solid black;
    margin-top:20px;
}

JavaScript

$(function() {

    $('#box').draggable();
    $('#box').contextmenu(function(e) {
        e.preventDefault();
        var doc_offset;
        boxWidth = $('#box').width();
   
        doc_offset = $(this).offset();
        doc_offset.left = doc_offset.left +  boxWidth + 20;
        $('<div>').css({width:"150px", 
                        height:"150px",
                        'background-color':'red',
                        position : 'absolute'
                       })
                 .offset(doc_offset)
                  .appendTo('body');  

        var scroll_left = $('body').scrollLeft();
        $('#scrollStatus').html("Scroll left is " + scroll_left);
        $('body').scrollLeft(scroll_left+doc_offset.left);
        
	 });
});