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

              
                <?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="diddy" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="500px" height="500px" viewBox="0 0 300 250" xml:space="preserve">
	<path fill="#AA4B3D" id="tail" d="M122.317,180.852c-2.587,3.4-5.47,6.578-8.673,9.406c-2.14,1.968-4.47,3.714-6.841,5.387
	c-2.408,1.621-4.895,3.13-7.487,4.438c-0.129,0.066-0.261,0.127-0.391,0.193l-0.141-0.178c0,0-5.354,2.72-9.591,4.174
	c-2.048,0.656-4.127,1.218-6.228,1.682c-1.428,0.265-2.844,0.598-4.288,0.771l-2.158,0.304l-2.17,0.201
	c-1.445,0.171-2.902,0.153-4.353,0.237c-1.403-0.01-2.918-0.068-4.372-0.101c-1.481,0.014-2.908-0.188-4.345-0.348
	c-1.436-0.175-2.88-0.263-4.301-0.6c-1.424-0.29-2.856-0.548-4.275-0.862l-4.194-1.201c-5.533-1.788-10.844-4.251-15.786-7.335
	c-4.89-3.164-9.368-6.945-13.337-11.205c-4.01-4.232-7.315-9.101-10.042-14.24c-1.437-2.54-2.488-5.268-3.597-7.96l-1.365-4.154
	c-0.093-0.276-0.169-0.562-0.255-0.842l-0.011,0.01c-1.396-4.873-5.024-3.173-3.911,2.567l1.1,4.048
	c1.027,2.942,2.017,5.936,3.415,8.753c2.616,5.714,6.042,11.116,10.223,15.893c4.147,4.801,8.883,9.14,14.148,12.802
	c4.282,2.818,8.853,5.207,13.625,7.14h-0.02c0.053,0.02,0.106,0.036,0.16,0.056c1.147,0.462,2.303,0.906,3.473,1.313l4.62,1.438
	c1.564,0.39,3.146,0.718,4.722,1.072c1.504,0.389,3.186,0.559,4.818,0.783c12.93,2.061,24.828,1.084,34.479-1.819
	c0.001,0.001,0.003,0.001,0.004,0.002c0,0,6.975-1.892,10.559-4.058l-0.194-0.246c5.739-3.174,5.477-4.281,3.234-4.497
	c0.903-0.575,1.8-1.162,2.682-1.77c2.633-1.89,5.21-3.868,7.578-6.082c3.773-3.4,7.136-7.231,10.12-11.331
	C126.742,183.414,124.529,182.132,122.317,180.852z"/>
	
	<path fill="#C03B3B" id="shirt-shadow" d="M160.932,163.462l-8.976,0.833l-3.052,1c0,0-9.473,19.167,1.527,14.667s17-2.72,17-2.72L160.932,163.462z"/>
	
	<g id="left-arm">
		<path fill="#D29B7D" id="left-hand" d="M157.825,200.912l-13.507,14.174l-0.444,12.513l4.122-0.785l1.28,3.255
		c11.41-2.498,16.785-10.805,16.785-10.805C165.417,212.666,157.825,200.912,157.825,200.912z"/>
		<path fill="#994339" id="left-sleeve" d="M125.637,148.821l-5.503,16.29c16.05,23.07,24.091,55.228,24.091,55.228
		c9.452-1.608,20.991-11.812,20.991-11.812C159.144,184.802,125.637,148.821,125.637,148.821z"/>
	</g>

	<g id="left-leg">
		<line fill="none" stroke="#AA4B3D" id="left-pant" stroke-width="11" stroke-miterlimit="10" x1="129.375" y1="203.919" x2="129.375" y2="239.162"/>
		<line fill="none" stroke="#E7AB85" id="left-foot" stroke-width="16" stroke-miterlimit="10" x1="129.375" y1="235.103" x2="129.375" y2="243.22"/>
	</g>
	<g id="right-leg">
		<line fill="none" stroke="#AA4B3D" id="right-pant" stroke-width="11" stroke-miterlimit="10" x1="108.688" y1="203.919" x2="108.688" y2="239.162"/>
		<line fill="none" stroke="#E7AB85" id="right-foot" stroke-width="16" stroke-miterlimit="10" x1="108.688" y1="235.103" x2="108.688" y2="243.22"/>
	</g>

	<g id="right-arm">
		<path fill="#E7AB85" id="right-hand" d="M76.511,218.457l-20.587-5.166c0,0-0.146,15.166,3.087,21.586c0,0,12.125,4.08,20.125,0.705l0.801-4.25
		l4.231-1.667L76.511,218.457z"/>
		<path fill="#AA4B3D" id="right-sleeve" d="M70.182,146.869l10.954-2.291l-4.448-12.494l-21.16,12c0,0-9.851,52.373-1.667,77.629
		c0,0,16.484,2.666,26.075-1.334C79.937,220.378,68.845,177.302,70.182,146.869z"/>
	</g>

	<g id="torso">
		<path fill="#AA4B3D" id="belly-shadow" d="M138.499,208.343c-13.849,3.325-28.832-9.886-31.897-22.654c-2.686-11.185,3.018-22.42,13.056-27.097
			l-40.23-0.499c6.803,10.086,14.696,26.567,13.624,47.848c6.709,10.02,24.013,15.438,36.423,12.458
			c8.728-2.095,15.612-7.854,19.431-15.249C145.97,205.579,142.452,207.394,138.499,208.343z"/>
		<path fill="#E7AB85" id="belly" d="M158.846,174.798c-5.423-13.016-12.047-13.761-12.047-13.761l-1.518,0.667
			c-4.868-9.718-14.682-3.486-25.624-3.112c-10.038,4.676-15.969,14.966-13.056,27.097l0,0c2.62,10.912,14.226,23.38,25.887,23.366
			l-0.003,0.003c0.051,0,0.098-0.004,0.147-0.005c0.424-0.003,0.849-0.016,1.275-0.04
			C158.357,209.058,164.144,187.513,158.846,174.798z"/>
		<path fill="#AA4B3D" id="belly-button" d="M143.008,197.713c0.294,0.863,0.335,2.691,1.361,2.343c1.026-0.35,2.648-2.742,2.354-3.606
			c-0.293-0.864-1.363-1.281-2.39-0.933S142.715,196.849,143.008,197.713z"/>

		<path fill="#EC4640" id="shirt" d="M121.037,140.533l-0.386-23.398c-12.973,6.755-69.003,17.786-69.003,17.786
			c38.079,18.125,36.244,60.664,36.03,60.574c0,0,24.637-24.659,59.121-24.659c8.368,0,14.466,0.627,20.633,6.407
			C161.334,140.998,129.827,142.358,121.037,140.533z"/>

			<path fill="none" stroke="#EACD40" id="necklace" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" d="
			M116.464,154.74c0,0,15.966,10.582,24.447,23.243c0,0,2.22-19.312-1.027-26.303"/>

		<path fill="#46464F" id="jacket-left" d="M151.371,144.108l-10.049,2.804c0,0,4.812,3.229,7.912,8.921c0,0,7.241-1.825,14.347-0.342
			C163.581,155.491,158.835,148.175,151.371,144.108z"/>
		<path fill="#46464F" id="jacket-right" d="M75.265,127.164l-20.918-1.675c-6.566,15.113-8.704,29.716-8.704,40.175
			c3.083,1.09,6.754,2.121,11.284,1.676c-0.053-3.518,0.922-7.096,3.231-11.058c0,0,0.321,8.251,2.904,11.898
			c5.395-0.749,10.235-3.349,10.235-3.349c-1.85-4.312-1.699-10.63-1.699-10.63c6.946,5.502,11.047,23.937,11.047,23.937
			c10.953-11.941,32.389-15.709,32.389-15.709C112.963,155.763,76.492,125.872,75.265,127.164z"/>
	</g>

	<g id="head">
		<path fill="#AA4B3D" id="hair" d="M100.123,58.182c-29.414-6.454-52.713,25.54-38,58.104c15,33.2,53.599,8.438,53.599,8.438l18.919-24.057
			C134.641,100.667,131.456,65.057,100.123,58.182z"/>

		<path fill="#E7AB85" id="chin" d="M167.529,114.238l1.722-4.735l-29.112-17.836c0,0-22.993-5.378-30.467-3.697l-35.828,14.947
			c0,0-3.454,29.838,15.344,46.356c4.18,3.942,9.122,6.771,14.352,8.236l0.001,0.001c2.174,0.609,4.397,0.981,6.637,1.101
			c33.252,3.562,59.322-24.863,63.388-40.191L167.529,114.238z"/>

		<path fill="#C03B3B" id="mouth" d="M116.616,130.652c-18.24-5.731-18.106,1.432-18.106,1.432c-2.482-2.39-3.146-6.766-3.284-9.871
			c-2.727-1.328-5.279-2.995-7.548-5.078c0,0-3.602,15.286,13.573,20.286c0.836,0.243,1.687,0.427,2.546,0.565
			c-0.782-0.974-1.484-2.053-1.772-3.065C102.024,134.92,110.5,134.098,116.616,130.652z"/>

		<path fill="#DEE7E9" id="teeth" d="M132.395,125.926c-9.57,1.347-25.089,2.17-37.169-3.714c-0.975,3.458,0.293,8.318,2.775,10.708l3.5-3.084
			c0,0,9.442,1.763,15.115,0.815c-6.116,3.446-14.592,4.269-14.592,4.269l-2.267,2.021c0,0,1.587,0.729,4.039,1.045
			c2.815,0.453,5.737,0.373,8.652-0.081c14.48-2.258,28.778-13.646,28.778-13.646S137.738,125.173,132.395,125.926z"/>

		<g id="sunglasses">
			<polygon fill="#3B3B44" id="sunglasses-shadow" points="71.765,81.292 84.831,102.167 104.338,91.133 111.765,89.263 119.003,87.97 132.849,90.127 
				136.682,71.625 	"/>
			<polygon opacity="0.77" fill="#616073" id="sunglasses-glare" points="94.021,80.526 92.291,98.085 100.391,93.366 102.731,86.963 111.856,88.449 
				117.333,85.542 120.19,88.155 126.154,89.084 128.181,75.042 	"/>
		</g>

		<g id="nose">
			<polygon fill="#E7AB85" id="nosey" points="119.126,84.232 112.747,87.619 102.118,85.888 95.958,102.738 131.083,95.167 	"/>
			<polygon fill="#AA4B3D" id="right-nostril" points="106.206,90.106 104.326,93.75 111.688,93.401 		"/>
			<polygon fill="#AA4B3D" id="left-nostril" points="118.901,88.566 120.651,90.269 117.601,92.925 		"/>
		</g>
	</g>

	<g id="hat">
		<path fill="#EC4640" id="hat-cap" d="M50.611,72.385c-9,17.782,4.895,34.096,4.895,34.096l6.024-14.147l0.643-9.685L72.739,62.29
			C72.739,62.29,59.952,53.932,50.611,72.385z"/>
		<path fill="#BB3433" id="hat-underside" d="M129.721,13.814c-8.185-16.311-22.988-17.038-36.91-8.06c-19.274,13.565-33.188,48.47-28.162,74.771
			c7.621-15.571,28.672-29.604,51.854-14.699c0,0,15.851-10.119,18.139-19.66C136.641,37.826,135.748,25.828,129.721,13.814z"/>
		<path fill="#EC4640" id="hat-detail" d="M92.811,5.754c-20.952,13.511-39.906,49.018-31.28,86.579c0.08-3.759,1.177-7.842,3.118-11.808
			C59.623,54.225,73.536,19.319,92.811,5.754z"/>
		<path fill="#EC4640" id="hat-bill" d="M61.531,92.333c0,0,0.834-9.56,6.113-16.873c0,0-1.323-28.643,9.715-47.396
			C88.397,9.31,96.17,0.962,109.672,0.014c0,0-24.87-1.834-42.56,37.608l-5.189,21.442l0.083,6.167"/>

		<path fill="#E7AB85" id="ear" d="M64.357,111.038c0,0-0.207-1.285-0.312-3.342c-0.11-3.525,0.098-9.658,1.886-14.787L41.524,79.705
			C41.524,79.705,30.157,116.555,64.357,111.038z"/>
	</g>

	<g id="clothing">
		<polygon fill="#D0DBDC" id="spike-1" points="50.599,123.437 52.954,128.852 56.682,129.244 57.053,125.706 "/>
		<polygon fill="#D0DBDC" id="spike-2" points="63.266,130.962 59.489,131.542 60.766,135.218 64.542,134.42 "/>
		<polygon fill="#D0DBDC" id="spike-3" points="60.661,123.285 59.224,125.879 63.429,126.215 "/>
		<circle fill="#EACD40" id="medal" cx="140.782" cy="181.646" r="5.468"/>
		<path fill="#3B3B44" id="jacket-shadow" d="M72.207,148.932c-0.309,1.606-0.561,3.43-0.608,5.27c6.094,5.808,11.047,23.937,11.047,23.937
			c2.41-2.799,9.982-7.662,9.982-7.662S85.787,156.796,72.207,148.932z"/>
	</g>
</svg>

              
            
!

CSS

              
                body
  background-color: mediumseagreen
    
// Original artwork made by Joseph Le: https://dribbble.com/josephle
              
            
!

JS

              
                var canvas = Snap("500px", "500px");

var diddy = document.getElementById("diddy");

// Add file to Snap object
canvas.append(diddy);

// Move svg into the window a bit
canvas.select("#diddy").attr({
  x: 50,
  y: 25
});
    
// Animation descriptions
var littleBounce = 't0,-2';
var littleSwing = 't-2,0';
var largeSwing = 't-4,0';

// Animation reset
var reset = 't0,0';

// Body parts in svg we want to move independently
var bodyParts = [
  hat =          [ canvas.select("#hat"), littleBounce, 750, mina.easeinout ],
  head =         [ canvas.select("#head"), littleBounce, 750, mina.easeinout ], 
  rightArm =     [ canvas.select("#right-arm"), largeSwing, 750, mina.easeinout ],
  leftArm =      [ canvas.select("#left-arm"), largeSwing, 750, mina.easeinout ],
  clothing =     [ canvas.select("#clothing"), littleBounce, 750, mina.easeinout ], 
  shirtShadow =  [ canvas.select("#shirt-shadow"), littleBounce, 750, mina.easeinout ],
  torso =        [ canvas.select("#torso"), littleBounce, 750, mina.easeinout ],
  necklace =     [ canvas.select("#necklace"), littleSwing, 750, mina.easeinout ], 
  medal =        [ canvas.select("#medal"), largeSwing, 750, mina.easeinout ],
  tail =         [ canvas.select("#tail"), littleBounce, 750, mina.easeinout ]
];

  // +1 for Ian http://stackoverflow.com/questions/24192964/animation-in-callback-not-firing-snapsvg
  var startBounce = function( bodyPart, transform, milliseconds, ease ) {
    bodyPart.stop().animate({
      transform: transform || littleBounce
    }, milliseconds, ease, endBounce.bind(null, bodyPart, transform, milliseconds, ease));
  };

  // Callback
  var endBounce = function( bodyPart, transform, milliseconds, ease ) {
      bodyPart.animate({ 
        transform: reset
      }, milliseconds, ease, startBounce.bind(null, bodyPart, transform, milliseconds, ease));
  };

  // Use body parts array as params for startBounce()
  var moveParts = function() {
    bodyParts.forEach( function(elem) {
      elem.forEach( function(elem, index){
        if (index === 0) {
          bodyPart = elem;
        } else if (index === 1) {
          transform = elem;
        } else if (index === 2) {
          milliseconds = elem;
        } else {
          ease = elem;
        }
      });
      startBounce(bodyPart, transform, milliseconds, ease);
    });
  }

  moveParts();
              
            
!
999px

Console