JSFiddle - React, Tailwind, and code Playground

by Oliver_kh

HTML

<div id="f"></div>
<div class="fl">
  <div id="r">NaN</div>
  <div id="moves">moves:<span id="moves_c">0</span>

  </div>
  <div id="sort">sort</div>
  <div id="db"></div>
  <div id="new_game">new game</div>
</div>

CSS

body {
  margin: 0;
  padding: 0;
}

#f {
  width: 100%;
  height: 200px;
  background: #ccc;
  overflow: hidden;
  position: relative;
}

#f>div {
  width: 25%;
  height: 25%;
  background: #eee;
  float: left;
}

#f>div.cl {
  background: #ccc;
}

#f>div.active {
  background: #eee;
}

#f>div>div {
  display: table;
  width: 100%;
  height: 100%;
}

#f>div>div>span {
  display: table-cell;
  vertical-align: middle;
  text-align: center;
  font-size: 19px;
  font-family: sans-serif;
}

.fl {
  position: fixed;
  padding: 10px;
  right: 0;
  bottom: 0;
}

JavaScript

$(function() {
   start = 0;
   var el = $('#f');
   new_game(el);
   $(window).keyup(function(e) {
     if (e.keyCode == 32) sort();
     if ($('#f>div').hasClass('action')) return;

     $("#r").text(e.keyCode);

     if (active_right || active_bottom || active_left || active_top) {
       $('#f').html(table_reset);
     }

     if (e.keyCode == 39 && active_right == true) {
       $('#f>div').addClass('action');
       var el = $('.go_right');
       //
       el.css({
         'position': 'absolute',

       });
       el.before('<div class="cl" />');
       el.animate({
         'left': el.position().left + el.width()
       }, 200, function() {
         el.nextAll('.cl').after(el);
         el.prev().remove();
         el.css({
           'position': 'static'
         });
         get_el_pos();
         final_ch();
         moves();
       });
     }
     if (e.keyCode == 40 && active_bottom == true) {
       $('#f>div').addClass('action');
       var el = $('.go_bt');
       //
       el.css({
         'position': 'absolute',

       });
       el.before('<div class="cl" />');
       el.animate({
         'top': el.position().top + el.height()
       }, 200, function() {
         el.nextAll('.cl').after(el);
         el.prev().remove();
         el.css({
           'position': 'static'
         });
         get_el_pos();
         final_ch();
         moves();
       });
     }
     if (e.keyCode == 37 && active_left == true) {
       $('#f>div').addClass('action');
       var el = $('.go_left');
       //
       el.css({
         'position': 'absolute',
       });
       el.after('<div class="cl" />');
       el.animate({
         'left': el.position().left - el.width()
       }, 200, function() {
         el.prevAll('.cl').before(el);
         el.next().remove();
         el.css({
           'position': 'static'
         });
         get_el_pos();
         final_ch();
         moves();
       });
     }
     if (e.keyCode == 38 && active_top == true) {
  ...