JSFiddle - React, Tailwind, and code Playground

by digitaloutback

HTML

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
<link type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/redmond/jquery-ui.css" rel="stylesheet" />

<span id="console"></span>
<div id="canvas">
    
    <span class="marquee"></span>
    <a class="layer" id='layer' href="#"></a>
    
</div>

CSS

#canvas { width: 500px; height: 500px; position: relative; overflow: hidden; background: #999}
#console {
    position: absolute ;
    z-index: 5000;
    white-space: pre ;
}
.marquee {
    border: 1px solid black;
    position: absolute;
    left: 150px; top: 150px;
    width: 250px; height: 226px;
    display: block;
    z-index: 2500;    
}

.layer {
    border: 1px dashed #fff;
    position: absolute;
    left: 150px; top: 150px;
    width: 250px; height: 226px;
    display: block;
    z-index: 2501;
}

JavaScript

$(document).ready(function() {

    $(".layer").resizable({
        //alsoResize: '.marquee',
        resize: function(event, ui) {
            $('#console').text('UI - Width: ' + ui.size.width
                             + ', Height: ' + ui.size.height
                             + ', Left: ' + ui.position.left
                             + ', Top: ' + ui.position.top
                             + '\n jQ - Width(): ' + $(this).width()
                             + ', Height(): ' + $(this).height()
                             + ', pos.left: ' + $(this).position().left
                             + ', pos.top: ' + $(this).position().top);
            $('.marquee').css({
                'left' : $(this).position().left,
                'top' : $(this).position().top,
                'width' : getSetWidth( $(this).width() ),
                'height' : getSetHeight( $(this).height() )
            });
        },
        handles: 'all',
        aspectRatio: true,
    });
    
    
    function getSetWidth(d) {
        $('.layer').width(d);  
        return d;
    }
    function getSetHeight(d) {
        $('.layer').height(d); 
        return d;
    }

});