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

              
                <h1 class="heading">gsap 3.0.2</h1>
<button type="button" value="false" class="toggle">draggable[0].vars.allowNativeTouchScrolling = </button>
<div id="container">
  <div id="menu">
    <div class="content-wrapper">
      <div class="content">
        <h3 class="title">This is the menu</h3>
        <p>Lorem ipsum dolor sit amet, consectetur  adipiscing elit. Sed a nunc tellus. Nam quis eros et arcu condimentum pharetra condimentum a massa. Nam ac vehicula orci. Sed eleifend urna sit amet lacinia sollicitudin. Praesent rhoncus tincidunt ex nec mattis. Quisque fringilla cursus odio at blandit. Nam laoreet elit vel fringilla tempor. Sed eleifend justo ex, quis tincidunt est ultrices nec. Vivamus quis orci rhoncus, malesuada ante a, convallis tellus. Praesent mollis, sem at ullamcorper gravida, velit arcu mollis eros, sed tincidunt enim nunc at libero. Cras varius dolor ut sapien tristique, non consectetur lectus molestie. Quisque facilisis sapien metus, ac placerat risus fermentum vel. Proin dapibus euismod ipsum, vel dapibus ex facilisis a. In nibh odio, efficitur quis lectus quis, ornare ultricies lorem. Nam sapien massa, euismod eget sodales id, hendrerit sit amet justo.</p>

        <p>Cras arcu leo, tristique vel dui non, congue varius enim. Nam in sapien fermentum, dictum sapien non, porta quam. Quisque dictum eros vestibulum, suscipit velit id, posuere lacus. Etiam egestas purus est, vel cursus risus commodo vel. Mauris tincidunt ut turpis porttitor porttitor. Morbi tristique, nisl a pellentesque sollicitudin, erat eros vehicula quam, quis posuere velit felis et eros. Aenean porttitor nec ligula sit amet rutrum. Nullam non commodo mauris, at interdum nulla. Nullam dolor ex, congue sit amet ipsum vitae, malesuada tristique eros. Proin suscipit, mi ut sagittis mollis, urna augue ultricies urna, non congue metus dui ut enim. Quisque facilisis eleifend urna, ut porttitor tortor accumsan nec. Phasellus eget bibendum mauris. Nunc turpis lectus, tincidunt vel aliquam vel, tempus quis tortor. In nec augue nec urna interdum placerat. Proin vitae scelerisque tortor. Fusce tempor ligula at lacus tempor posuere.</p>

        <p>Ut mi justo, fermentum nec varius et, vulputate sed massa. Cras ornare lorem in rutrum egestas. Duis hendrerit, tellus sit amet malesuada pretium, ipsum turpis commodo ligula, at accumsan arcu nisi nec sem. Aenean at efficitur sem. In hac habitasse platea dictumst. Donec condimentum nisi a tortor volutpat, non porta mi convallis. Fusce at sem cursus, maximus ante eu, facilisis libero. Morbi mattis est in risus tempor imperdiet. Aliquam imperdiet aliquam dolor ac cursus. Sed eget ex purus. Nullam placerat nisl id lacus maximus, interdum lobortis tellus dictum. Pellentesque hendrerit finibus dui sit amet volutpat.</p>
        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed a nunc tellus. Nam quis eros et arcu condimentum pharetra condimentum a massa. Nam ac vehicula orci. Sed eleifend urna sit amet lacinia sollicitudin. Praesent rhoncus tincidunt ex nec mattis. Quisque fringilla cursus odio at blandit. Nam laoreet elit vel fringilla tempor. Sed eleifend justo ex, quis tincidunt est ultrices nec. Vivamus quis orci rhoncus, malesuada ante a, convallis tellus. Praesent mollis, sem at ullamcorper gravida, velit arcu mollis eros, sed tincidunt enim nunc at libero. Cras varius dolor ut sapien tristique, non consectetur lectus molestie. Quisque facilisis sapien metus, ac placerat risus fermentum vel. Proin dapibus euismod ipsum, vel dapibus ex facilisis a. In nibh odio, efficitur quis lectus quis, ornare ultricies lorem. Nam sapien massa, euismod eget sodales id, hendrerit sit amet justo.</p>

        <p>Cras arcu leo, tristique vel dui non, congue varius enim. Nam in sapien fermentum, dictum sapien non, porta quam. Quisque dictum eros vestibulum, suscipit velit id, posuere lacus. Etiam egestas purus est, vel cursus risus commodo vel. Mauris tincidunt ut turpis porttitor porttitor. Morbi tristique, nisl a pellentesque sollicitudin, erat eros vehicula quam, quis posuere velit felis et eros. Aenean porttitor nec ligula sit amet rutrum. Nullam non commodo mauris, at interdum nulla. Nullam dolor ex, congue sit amet ipsum vitae, malesuada tristique eros. Proin suscipit, mi ut sagittis mollis, urna augue ultricies urna, non congue metus dui ut enim. Quisque facilisis eleifend urna, ut porttitor tortor accumsan nec. Phasellus eget bibendum mauris. Nunc turpis lectus, tincidunt vel aliquam vel, tempus quis tortor. In nec augue nec urna interdum placerat. Proin vitae scelerisque tortor. Fusce tempor ligula at lacus tempor posuere.</p>

        <p>Ut mi justo, fermentum nec varius et, vulputate sed massa. Cras ornare lorem in rutrum egestas. Duis hendrerit, tellus sit amet malesuada pretium, ipsum turpis commodo ligula, at accumsan arcu nisi nec sem. Aenean at efficitur sem. In hac habitasse platea dictumst. Donec condimentum nisi a tortor volutpat, non porta mi convallis. Fusce at sem cursus, maximus ante eu, facilisis libero. Morbi mattis est in risus tempor imperdiet. Aliquam imperdiet aliquam dolor ac cursus. Sed eget ex purus. Nullam placerat nisl id lacus maximus, interdum lobortis tellus dictum. Pellentesque hendrerit finibus dui sit amet volutpat.</p>
      </div>
    </div>
  </div>
</div>

              
            
!

CSS

              
                body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-size: 1em;
  color: white;
  background-color: black;
}
.heading {
  position: absolute;
  top: 0;
  left: 50%;
  text-align: center;
}
#container {
/*   height: 100vh; */
  overflow-y: hidden;
  width: 30em;
  background-color: white;
}
#menu {
/*   height: 100vh; */
  width: 25em;
  padding-right: 2em;
/*   border-color: rgba(255, 255, 255, 0.2); */
  background-color: rgba(0, 0, 0, 0.1);
  outline: 1px solid red;
}
#menu .content-wrapper {
  background-color: #222;
  height: 100vh;
  overflow-y: scroll;
}
#menu .content-wrapper::-webkit-scrollbar {
  display: none;
}
#menu .content {
  padding: 0.5em 1em;
  margin-right: 0;
}
#menu .title {
  text-align: center;
  margin-top: 0;
}
button.toggle {
  position: fixed;
  top: 50%;
  left: 50%;
  padding: 0.5em 1em;
  border-radius: 0.5em;
  background-color: #ccc;
}
              
            
!

JS

              
                var menu = $("#menu");
var closedX, openX;
closedX = - menu.width();
openX = 0;
var grid = [openX, closedX];
var draggable = Draggable.create(menu, {
  type: "x",
  bounds: {minX: closedX, maxX: openX},
  edgeResistance: 1,
  allowNativeTouchScrolling: true,
  onDrag: function() {
    console.log("x = " + this.x);  
  },
  onDragStart: function(e) {
    // Doesn't work.
    // this.vars.allowNativeTouchScrolling = false;
    // updateButton('draggable[0].vars.allowNativeTouchScrolling = ' + draggable[0].vars.allowNativeTouchScrolling);
  },
  inertia: true,
    snap: function(endValue) {
      var i;
      var newEndValue = 0;
      var diff = [];
      for (i = 0; i < grid.length; i++) {
        diff[i] = Math.abs(endValue - grid[i]);
      }
      for (i = 0; i < diff.length; i++) {
        if (i == 0) {
          newEndValue = 0;
        }
        else {
          if (diff[i] < diff[newEndValue]) {
            newEndValue = i;
          }
        }
      }
      return grid[newEndValue];
    }
});

$("button.toggle").off().on("click", function() {
  if (draggable[0].vars.allowNativeTouchScrolling === true) {
    draggable[0].vars.allowNativeTouchScrolling = false;
  }
  else {
    draggable[0].vars.allowNativeTouchScrolling = true;
  }
  updateButton('draggable[0].vars.allowNativeTouchScrolling = ' + draggable[0].vars.allowNativeTouchScrolling);
});
$("button.toggle").trigger("click");

function updateButton(text) {
    $("button.toggle").html(text);
}
              
            
!
999px

Console