cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

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.

            
              <div id="wrapper">
  <div id="rotate-container">
    <div id="rotatable">
      <div style="text-align:center;">Rotate me <br> <span style="font-size:0.5em">(1 or 2-Fingers)</span><br><i class="fa fa-undo" aria-hidden="true"></i></div>

    </div>
  </div>
  <div id="output">> Interaction meta will output here.</div>
</div>


<div id="interaction" style=""></div>
            
          
!
            
              *{
  box-sizing: border-box;
}
body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: 'Helvetica', Arial;
}
#wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
}

#output {
  background-color: #3B3B3B;
  width: 100%;
  display: block;
  min-height: 30px;
  padding: 10px;
  font-size: 0.8em;
  color: white;
}

#rotate-container{
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  color: white;
  cursor: pointer;
}

#rotatable {
  display: flex;  
  flex-direction: column;
  align-items: center;
  justify-content: center; 
  background-color: #fff;
  width: 200px;
  height: 200px;
  font-size: 2rem;
background: linear-gradient(to left, #f46b45 , #eea849); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */


}
#interaction {
  position: fixed;
  top: 0;
  height: 100vh;
  width: 100%;
  z-index: 1000;
}

            
          
!
            
              var currentAngle = 15;
//Using a layer on top of the entire page for "fat-finger" detection on mobile devices.
document.getElementById('rotatable').style.transform = 'rotate(15deg)';

var target = document.getElementById('interaction');
var region = new ZingTouch.Region(target);

region.bind(target, 'rotate', function(e) {
  var rotatable = document.getElementById('rotatable');
  currentAngle += e.detail.distanceFromLast;
  rotatable.style.transform = 'rotate(' + currentAngle + 'deg)';

  setOutput([
    ['Gesture', 'Rotate'],
    ['angle', Math.floor(e.detail.angle) + "°"],
    ['distanceFromOrigin', Math.floor(e.detail.distanceFromOrigin) + "°"],
    ['distanceFromLast', Math.floor(e.detail.distanceFromLast) + "°"]
  ]);

});

function setOutput(data) {
  var outputStr = "> ";
  for (var i = 0; i < data.length; i++) {
    outputStr += data[i][0] + ": " + data[i][1] + ((i === data.length - 1) ? '' : ' , ');
  }
  var output = document.getElementById('output');
  output.innerHTML = outputStr;
}
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console