Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs 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 its URL and the proper URL extension.

+ 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 class='spriteslider' id='spriteslider'>
  <div id='spritetarget'></div>

<p>Drag the box left/right to control the sprite's position.</p>


                body {
  text-align: center;
  font: normal 12px sans-serif;
  background: #000000;
  color: #91E600;
.spriteslider {
  margin: 20px auto;
  padding: 60px;    
  width: 128px;
  background: #FCFEFC;
  border-radius: 5px;
#spritetarget {
  width: 128px;
  height: 128px;
  background-image: url(; /* horizontal spritesheet - image from */
  background-repeat: repeat-x;


                // use a dummy element as the target since we don't really need anything visual to drag around
var spriteslider = document.createElement('div');
// the dummy element needs to be added to the DOM in latest Draggable

// attach all vars to the dummy element so globals aren't needed:
// element that initiates dragging
spriteslider.slider = document.getElementById('spriteslider');
// element with the sprite sheet to control
spriteslider.sprite = document.getElementById('spritetarget');
// size of each sprite frame
spriteslider.spritesize = 128;
// number of sprite frames - used to keep multiplier in a reasonable range
spriteslider.spritecount = 20;
// pixels to drag per sprite update
spriteslider.pixelsperincrement = 25;
// values used by the sprite changer
spriteslider.multiplier = spriteslider.lastmultiplier = 0;

// create the 360 degree slider
Draggable.create(spriteslider, {
  	type: 'x',
  trigger: spriteslider.slider,
  // reset the targets position after drag ends, so onDrag doesn't need to deal with an offset
  bounds: { minX:0, maxX:0, minY:0, maxY:0 },
  // don't need to slow down as you drag further away
	  edgeResistance: 0,
  cursor: 'e-resize',
  onDrag: function() {
    // there is an extra drag event fired on mouse up that has x = 0, so check this.isDragging to skip that last one
    if (this.isDragging) {
      var t =; // the dummy div
      t.multiplier = Math.floor(this.x / t.pixelsperincrement) + t.lastmultiplier;
      TweenLite.set(t.sprite, { backgroundPosition: (-t.multiplier * t.spritesize) + "px 0"});
	  onDragEnd: function()	{
    // saves the current multiplier, and keeps multiplier small so that backgroundPosition doesn't end up too large for the browser to render
    var t =; // the dummy div
    t.lastmultiplier = t.multiplier % t.spritecount;