Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


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


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.


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.


                <div id="container">
  <div id="some-text">
  Throw the box left or right, then re-grab and drag vertically before its horizontal motion comes to a stop. As soon as the "horizontalTween" completes, the very next pixel that you drag vertically will make the box jump by the distance you dragged vertically.
  <div class="box red" id="redBox"></div>


                body {
  font-family: sans-serif;

#container {
  width: 100vw;
  height: 100vh;

#some-text {

h1 {
  margin: 5px 0;

h3 {
  margin: 0;
  font-size: 16px;

.demo {
  width: 600px;
  height: 120px;
  background-color: black;
  position: relative;

.box {
  width: 150px;
  height: 150px;
  position: relative;
  margin-bottom: 2px;

.red {
  background-color: red;

.blue {
  background-color: blue;

.green {
  top: 60px;
  left: 25px;
  background-color: green;

.nav {
  width: 600px;
  background-color: #ccc;
  text-align: right;


                //var tl = new TimelineLite();

//".red", 1, {x:500})
//  .to(".blue", 1, {x:500})
var horizontalTween;

var dragContainer = Draggable.create("#redBox", {
  type: "x,y",
  lockAxis: true,
  //edgeResistance: 0.8,
  edgeResistance: 1,
  throwProps: true,
  throwResistance: 1200,
  minDuration: 0,
  dragClickables: true,
  zIndexBoost: false,
  onLockAxis: function() {
    if (this.lockedAxis === "x") {
      //this.vars.maxDuration = 5;

      horizontalTween ="#redBox", 2, {
        x: "500px",
        onComplete: function() {

      //dragContainer[0].edgeResistance = 1;
    } else {
      //this.vars.maxDuration = 0.6;
      horizontalTween && horizontalTween.kill();
  bounds: "#container"