Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

            
              <div class="content"> 
    <div id="section"> <div id="toolbar">
        <div id="drag"></div>
        <img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button2.png" id="changeD">
        <img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button3.png" id="changeA">
        <img src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button4.png" id="changeF">
        </div>
    <div id="dragonImg">
    
    </div>
    <img id="dragon" src="https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon1.png"> 

    <h1>Realest Real Estate :-)</h1>
    <h3></h3>
    <p><br>
    Any white man can sell you a home - it's just a bunch of papers you need to sign!<br>
    What we at "Realest Real Estate :-)"&trade; promise is a unique, revolutionary home-buying experience. No more boring "open houses" or "meetings" about "your needs, expectations and budget".<br><br>
    Here at "Realest Real Estate :-)"&trade; we promise a once in a life time home purchasing adventure! Three masked men will whisk you away from your current residence under the cover of the darkest of nights, and drive you by carriage to the proscpective house. You will be bound, gagged and covered in masking-tape and wood shavings. The music will be loud and very European. After you have experienced every lovely room in the house, three cats will be released from crates. You must choose the best cat, and it is yours to keep. If you wish to buy the house you are currently in, <b>CONGRATULATIONS ON YOUR NEW HOUSE!!!</b> If, however, you wish to keep looking - you must simply figure out the next address.
    </p><br><br>


    <iframe id="player" frameborder="0" allowfullscreen="1" title="YouTube video player" width="854" height="480" 
    src="https://www.youtube.com/embed/DCu1G2rxj5c?enablejsapi=1&origin=http%3A%2F%2Fmgapcdev.com"></iframe><br>
    
    <button type="button" id="clearDragon">Clear Dragon-Drops</button> 

    <div style="clear:both"></div>
    </div>
</div>
            
          
!

CSS

            
              .content #drag{
    cursor: pointer;
}
#dragon{
    display: none;
    opacity: 0.7;
    position: absolute;
    height: 300px;
    border: 3px solid rgba(0,0,0,0);
}
.dragon{
    position: absolute;
    height: 300px;
    border: 3px solid rgba(0,0,0,0);
}
.border_dragon{
    border: 3px dashed black;
}
.flip-horizontal {
    -moz-transform: scaleX(-1);
    -webkit-transform: scaleX(-1);
    -o-transform: scaleX(-1);
    transform: scaleX(-1);
    -ms-filter: fliph; /*IE*/
    filter: fliph; /*IE*/
}
#toolbar{
    position: absolute;
    top: 75px;
    left:0;
    height: 644px;
    width: 189px;
    background-image: url(https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/toolbar.png);
    padding-top: 125px; 
    background-repeat: no-repeat;
    z-index: 95;
}
#toolbar img, #toolbar div{
    position: relative;
    margin: 10px;
    margin-left: 30px;
    cursor: pointer;
}
#toolbar #drag{
    background-image: url(https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon_button5.png);
    width: 102px;
    height: 100px;
}
            
          
!

JS

            
              var varX;
var varY;
var varSrc;
var highlight_element;
var dragonNum = 0;
var defaultSrc = 'https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/dragon1.png';

var baseURL = 'https://raw.githubusercontent.com/MGApcDev/Dragon-Drop/refactor-everything/images/';
var extension = '.png';
var dragon1 = baseURL + "dragon1" + extension;
var dragon2 = baseURL + "dragon2" + extension;
var dragon3 = baseURL + "dragon3" + extension;
var dragon4 = baseURL + "dragon4" + extension;

$(document).ready(function(){
    $('.dragon').removeClass('border_dragon');
    dragonNum = $('#totalDragon').attr('totalDragon');
    $("#drag").draggable({helper:"clone",
      start: function() {
        // Nothing
      },
      drag: function(event) {
          event = event || window.event;
          varX = event.clientX -100;
          varY = event.clientY -100;
          $('#dragon').show().css('top',event.clientY-100).css('left',event.clientX-100);
      },
      stop: function() {
          $('#dragon').hide();
          $('#dragonImg').append('<img src="'+dragon1+'"" style="top:'+varY+'px; left:'+varX+'px;" class="dragon" dragonNum="'+dragonNum+'">');
          /*
          $.post(
              '/php/article/dragonDrop/setDragonCookie.php',
              {dragonSrc: defaultSrc, dragonTop: varY+'px', dragonLeft:varX+'px', dragonClass:'dragon', num: dragonNum}
          );*/
          dragonNum++;
      }
    });
    /**
     * Refreshes which 'dragon' to highlight.
     */
    $(document).on('click', '.dragon',function(){
        $('.dragon').removeClass('border_dragon');
        $(this).addClass('border_dragon');
        highlight_element = $(this);
        varSrc = highlight_element.attr('src');
    });
    /**
     * Changes between the two 'dragons'.
     */
    $('#changeD').click(function(){
        varSrc = highlight_element.attr('src');
        switch(varSrc){
            case dragon1:
                changeSrc(dragon2);
                break;
            case dragon2:
                changeSrc(dragon1);
                break;
            case dragon3:
                changeSrc(dragon4);
                break;
            case dragon4:
                changeSrc(dragon3);
                break;
        }
        getAttr();
        setCookie();
    });
    
    /**
     * Changes whether to show an ad on 'dragon'.
     */ 
    $('#changeA').click(function(){
        varSrc = highlight_element.attr('src');
        switch(varSrc){
            case dragon1:
                changeSrc(dragon3);
                break;
            case dragon2:
                changeSrc(dragon4);
                break;
            case dragon3:
                changeSrc(dragon1);
                break;
            case dragon4:
                changeSrc(dragon2);
                break;
        }
        getAttr();
        setCookie();
    });
    
    /**
     * Creates a copy of selected dragon and flips it horizontally.
     */
    $('#changeF').click(function(){
        varSrc = highlight_element.attr('src');
        topV = highlight_element.css('top');
        topV = topV.replace(/\D/g,'');
        leftV = highlight_element.css('left');
        
        if(varSrc == dragon1 || varSrc == dragon3){
            leftV = parseInt(leftV.replace(/\D/g,'')) - 341;
        }else if(varSrc == dragon2 || varSrc == dragon4){
            leftV = parseInt(leftV.replace(/\D/g,'')) - 248;
        }        

        $('#dragonImg').append('<img src="'+varSrc+'" style="top:'+topV+'px; left:'+leftV+'px;" class="dragon flip-horizontal" dragonNum="'+dragonNum+'">');
        /*$.post(
            '/php/article/dragonDrop/setDragonCookie.php',
            {dragonSrc: varSrc, dragonTop: topV+'px', dragonLeft:leftV+'px', dragonClass:'dragon flip-horizontal', num: dragonNum}
        );*/
        dragonNum++;
        getAttr();
        setCookie();
    });
    
    /**
     * Removes highlight if click event doesn't hit toolbar or a dragon.
     */
    $(document).click(function(e) {
        if ( $(e.target).closest('.dragon').length === 0 ) {
            if ( $(e.target).closest('#toolbar').length === 0 ) {
                $('.dragon').removeClass('border_dragon');
                highlight_element = null;
            }
        }
    });
    
    /**
     * Clears all cookies that specify dragons and refreshes page.
     */
    $('#clearDragon').click(function(){
        /*$.post('/php/article/dragonDrop/clearDragonCookie.php', function(){
            window.location.href = "/project/dragon-drop-demo";
        });*/
    });
});

var topPX;
var leftPX;
var varClass;
var varDragon;

/**
 * Changes the source of highlighted element
 */
function changeSrc(source){
     highlight_element.attr('src', source);
}

/**
 * Refreshes the attributes on the highlighted element.
 */
function getAttr(){
    varSrc = highlight_element.attr('src');
    topPX = highlight_element.css('top');
    leftPX = highlight_element.css('left');
    varClass = highlight_element.attr('class');
    varDragon = highlight_element.attr('dragonNum');
}

/**
 * Updates the highlighted dragon's cookie.
 */
function setCookie(){
    /*$.post(
        '/php/article/dragonDrop/setDragonCookie.php',
        {dragonSrc: varSrc, dragonTop: topPX, dragonLeft: leftPX, dragonClass: varClass, num: varDragon}
    );*/
}
            
          
!
999px

Console