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="wrapper">
  <div id="left-column">
    <h3>Draggable items</h3>
    <div class="draggable-item">Draggable item 1</div>
    <div class="draggable-item">Draggable item 2</div>
    <div class="draggable-item">Draggable item 3</div>
  <div id="right-column">
    <h3>Drop areas</h3>


                /* Sample related CSS */
body {
  background: #ccc;

#right-column {
  background: #fff;

#wrapper {
  display: flex;
  width: 100%px;
  justify-content: space-between;

#left-column {
  width: 40%;

#right-column {
  width: 40%;

#left-column h3,
#right-column h3 {
  text-align: center;

.draggable-item {
  padding: 10px;

/* Drag and drop related CSS */
.draggable-item.animatable {
  transition: transform linear 400ms;


                /* Creates an array of draggable items */
let draggableItems = document.querySelectorAll('.draggable-item');

let initialX;
let initialY;
let offsetX = 0;
let offsetY = 0;

/* Creates a handler for each event listener */
let touchStartHandler = function(event) {
  interactionStart(, event.touches[0].pageX, event.touches[0].pageY);

let touchMovetHandler = function(event) {
  interactionMove(, event.touches[0].pageX, event.touches[0].pageY);

let touchEndtHandler = function(event) {
  interactionEnd(, event.changedTouches[0].pageX, event.changedTouches[0].pageY);

/* Create handlers to each interaction */
let interactionStart = function(element, coordX, coordY) {
  initialX = coordX;
  initialY = coordY;

let interactionMove = function(element, coordX, coordY) {
  offsetX = coordX - initialX;
  offsetY = coordY - initialY;

let interactionEnd = function(element, coordX, coordY) {
  // Will be called inside the touch handlers or any other handler responsible to the movement

/* Creates the necessary functions */
let addEventListeners = function(element) {
  /* Touch related events */
  element.addEventListener('touchstart', touchStartHandler);
  element.addEventListener('touchmove', touchMovetHandler);
  element.addEventListener('touchend', touchEndtHandler);

/* Executes a function to create all event listeners */
draggableItems.forEach(function(draggableItem) {