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

              
                <script src="https://hammerjs.github.io/dist/hammer.js"></script>

<div class="desc">Drag left to see the effect</div>

<nav class="side-menu">
  <a class="icon icon-tap">1</a>
  <a class="icon icon-tap">2</a>
  <a class="icon icon-tap">3</a>
</nav>
              
            
!

CSS

              
                html,
body {
  width: 100%;
  height: 100%;
}

body {
  font-family: "Segoue UI", Arial, sans-serif;
  background: #eee;
}

/*
 * Side menu
 *
 */

.side-menu {
    height: 100%;
    position: fixed;
    top: 0;
    right: 0;
    padding: 70px;
    background: #FDB351;
    background: -webkit-linear-gradient(45deg, #FDB351 0%, #F28543 100%);
    background:         linear-gradient(45deg, #FDB351 0%, #F28543 100%);
}

.side-menu a {
    display: block;
    text-decoration: none;
    color: #fff;
}

/*
 * Tap rings
 *
 */

.icon-tap {
    position: relative;
    width: 50px;
    height: 50px;
    line-height: 50px;
    font-size: 18px;
    text-align: center;
    color: #E2913E;
    margin: 20px 0 0 0;
    border: 2px solid;
    border-radius: 999px;
}

.icon-tap:hover {
    cursor: pointer;
}

.desc {
  padding: 30px;
}
              
            
!

JS

              
                // Enable touch gestures
// Create global Hammer.js instance
// https://hammerjs.github.io/api/
var mc = new Hammer(document.body);
mc.get('pan').set({ direction: Hammer.DIRECTION_ALL });

// Create menu slide tween
slide = TweenMax.fromTo('.side-menu' , 2, { x:'90%', opacity:.9 }, { x:'0%', opacity:.9, display:'block' }).paused(true);

// Listen for touch gestures
mc.on("panleft", function(e) {
  var distance = Math.floor(e.distance) / 100;
  
  // Constrain distance
  ( Math.abs(distance) > 1 ) ? distance = 1 : "";
  console.log(distance);

  // Jump to progress position
  // Slow down animation
  slide.timeScale(2).progress(distance);
});

mc.on("panend", function() {
  console.log('release');

  // Get current time
  var currentAnimPos = slide.time();

  // Play from position where release happened
  // This one makes trouble, so I commented it out
  // slide.play(currentAnimPos);
});
              
            
!
999px

Console