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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

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

Visit your global Editor Settings.

HTML

              
                <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>
              
            
!

CSS

              
                *{
  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;
}

              
            
!

JS

              
                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

Console