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='status'></div>

<div class='draggable'>
  <div class='clickable'>1</div>
  <div class='clickable'>2</div>
  <div class='clickable'>3</div>


                .draggable {
  background: #888;
  display: inline-block;
  padding: 50px;
  border-radius: 5px;
  margin-left: 20px;
.clickable {
  color: #FFF;
  background: #222;
  width: 50px;
  height: 50px;
  line-height: 50px;
  border-radius: 3px;
  margin-right: 50px;
  float: left;
  cursor: pointer;
  text-align: center;
.clickable:last-child {
  margin-right: 0;

#status {
  background: #222;
  color: #EEE;
  padding: 20px;
  margin-bottom: 20px;
  line-height: 1em;
  height: 1em;


                window.draginfo = { x:0, y:0 };

var clickfunction = function() {
  var x = window.draginfo.x - window.drag.pointerX;
  var y = window.draginfo.y - window.drag.pointerY;
  // only respond if there wasn't much movement on the click. I suppose if you dragged it around a bunch but dropped it back in the same place it would still trigger...
  if (x < 2 && x > -2 && y < 2 && y > -2) {
    $('#status').append(' - <u>clicked .clickable ' + $(this).text() + '</u>');
    // this is where the real meat of the click function would exist

// set up some clickable things
$('.clickable').attr('data-clickable', true).on('click touchend', clickfunction);

// create a draggable with clickable and draggable elements
window.drag = Draggable.create('.draggable', {
  dragClickables: true,
  onDragStart: function() {
    window.draginfo = {
      x: this.pointerX,
      y: this.pointerY
    $('#status').text('drag start');
  onDragEnd: function() {
    $('#status').append(' - drag end');
  onClick: function(e) {
    if( === $('#status').append(' - <u>clicked .draggable</u>');
// Draggable.create() returns an array of draggables - one per target element - in this demo we are only creating one so we'll just keep the reference to that