JSFiddle - React, Tailwind, and code Playground

by Nick Hulea

HTML

<script src="http://wellcaffeinated.net/PhysicsJS/examples/physicsjs-full.js"></script>
<script src="http://www.google.com/uds/api?file=uds.js&amp;v=0.1"></script>

<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_1.png">
<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_2.png">
<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_3.png">
<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_4.png">
<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_5.png">
<img class="physics-element" src="https://raw.githubusercontent.com/naeluh/cat/matter-dev/src/assets/cat_6.png">

CSS

body {
  margin: 0;
  overflow: hidden;
  font-family: Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -o-user-select: none;
  -ms-user-select: none;
    background: -moz-linear-gradient(top,  rgba(239,49,249,1) 0%, rgba(125,185,232,0) 100%);
  background: -webkit-linear-gradient(top,  rgba(239,49,249,1) 0%,rgba(125,185,232,0) 100%);
  background: linear-gradient(to bottom,  rgba(239,49,249,1) 0%,rgba(125,185,232,0) 100%);
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ef31f9', endColorstr='#007db9e8',GradientType=0 );
}

button {
  height: 29px;
  padding: 0 8px 1px 8px;
  color: #444;
  background-color: #f4f4f4;
  border: 1px solid #d9d9d9;
  border-radius: 2px;
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: bold;
  text-align: center;
  cursor: pointer;
}

button:hover {
  color: #222;
  background-color: #f8f8f8;
  border: 1px solid #c6c6c6;
  -webkit-box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
}

#header {
  position: absolute;
  top: 15px;
  right: 0px;
}

#header a {
  color: #444;
  font-size: 13px;
  margin-right: 15px;
  text-decoration: none;
}

#header a:hover {
  text-decoration: underline;
}

#header img {
  vertical-align: middle;
}

#header button {
  margin-right: 15px;
}

#content {
  width: 100%;
  text-align: center;
  margin-top: 192px;
  white-space: nowrap;
}

#content #logo {
  margin-bottom: 17px;
}

#content input {
  width: 560px;
  padding: 5px 8px;
  margin-bottom: 16px;
  font: 16px Arial, sans-serif;
  border: 1px solid rgba(0, 0, 0, .15);
  color: #000000;
}

#content input:hover {
  border-color: rgba(0, 0, 0, .3);
}

#content input:focus {
  outline: 0;
  /* this removes browser-side outline */
  border-color: #4d90fe;
}

#footer {
  position: absolute;
  bottom: 0px;
  width: 100%;
  font-size: 13px;
  border-spacing: 0;
  white-space: nowrap;
}

#footer td {
  border-top: 1px solid #e4e4e4;
 ...

Babel + JSX

const delta = [0, 0];
const stage = [window.screenX, window.screenY, window.innerWidth, window.innerHeight];
getBrowserDimensions();

const isRunning = false;
let isMouseDown = false;

let worldAABB;
let world;
let edgeBounce;
const iterations = 16;
const timeStep = 1000 / 260;

let constraints;
let mouseJoint;
const mouse = {
  x: 0,
  y: 0
};

const mouseOnClick = [];

let elements = [];
const bodies = [];
const properties = [];

let query;
let page = 0;
let gWebSearch;
let gImageSearch;
let imFeelingLuckyMode = false;
const resultBodies = [];

const gravity = {
  x: 0,
  y: 1
};
let gravityBehavior;

init();
run();

//

function init () {
  document.addEventListener('mousedown', onDocumentMouseDown, false);
  document.addEventListener('mouseup', onDocumentMouseUp, false);
  document.addEventListener('mousemove', onDocumentMouseMove, false);

  document.addEventListener('keyup', onDocumentKeyUp, false);


  document.addEventListener('touchstart', onDocumentTouchStart, false);
  document.addEventListener('touchmove', onDocumentTouchMove, false);
  document.addEventListener('touchend', onDocumentTouchEnd, false);

  window.addEventListener('deviceorientation', onWindowDeviceOrientation, false);

  // init PhysicsJS

  worldAABB = Physics.aabb.apply(null, stage);

  world = Physics({
    timestep: timeStep,
    maxIPF: iterations
  });

  // walls
  edgeBounce = Physics.behavior('edge-collision-detection', {
    aabb: worldAABB,
    restitution: 0.75,
    cof: 0.75
  });
  world.add(edgeBounce);

  //world.add(Physics.behavior('body-collision-detection', {
  //  checkAll: false
  //}));
  world.add(Physics.behavior('sweep-prune'));
  world.add(Physics.behavior('body-impulse-response'));

  // constraints
  constraints = Physics.behavior('verlet-constraints', {
    iterations: 2
  });
  world.add(constraints);

  // add gravity
  gravityBehavior = Physics.behavior('constant-acceleration', {
    acc: gravity
  });
  world.add(gravityBehavior);

  // Get...