HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
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.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<svg xmlns="http://www.w3.org/2000/svg" id="demo" viewBox="0 0 1000 1000">
<title>Alien Gooey Dial</title>
<defs>
<filter id="alienGoo">
<fegaussianblur in="SourceGraphic" stdDeviation="24" result="blur" />
<fecolormatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 28 -8" result="goo" />
<feblend in="SourceGraphic" in2="goo" />
</filter>
<filter id="gooDrip">
<fegaussianblur in="SourceGraphic" stdDeviation="10" result="blur" />
<fecolormatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 24 -7" result="goo" />
<feblend in="SourceGraphic" in2="goo" />
</filter>
<clippath id="theClipPath">
<rect x="325" y="500" width="350" rx="8" ry="8" height="180"/>
</clippath>
<filter id="glow" x="-50%" y="-50%" width="200%" height="200%">
<fegaussianblur id="glowBlur" stdDeviation="14" result="blur"/>
<femerge>
<femergenode in="blur"/>
<femergenode in="SourceGraphic"/>
</femerge>
</filter>
</defs>
<!-- control panel screen -->
<rect x="325" y="500" width="350" height="180" rx="8" ry="8" opacity="0.5" stroke="#9f9f9f" stroke-width="2"/>
<g id="spinner" transform="translate(0 -30)">
<line x1="500" y1="100" x2="500" y2="200" fill="none" stroke="#b3b3b3" stroke-miterlimit="10" stroke-width="10"/>
<line x1="500" y1="100" x2="500" y2="200" fill="none" stroke="#fff" stroke-miterlimit="10" stroke-width="6"/>
<circle cx="500" cy="100" r="36" fill="#8cbc08" stroke="#fff" stroke-width="2" stroke-miterlimit="10"/>
<g id="alienLogo">
<path d="M503.15,111.79H503a.26.26,0,0,1-.25-.25V109.4l-.2,0-.16,0-.56,0h-.07l-.57,0-.14,0-.22,0v2.14a.25.25,0,0,1-.25.25h-.1a3.43,3.43,0,0,0-3.23,2.29.26.26,0,0,1-.22.17h-.31a2.34,2.34,0,0,1-2.15-1.16,11.89,11.89,0,0,1-1.2-3.07.14.14,0,0,1-.05-.08l-1-3L491,101.69a.54.54,0,0,0-1,.27l.77,2.93a.25.25,0,0,1-.42.24l-2.12-2.22a.53.53,0,0,0-.74,0,.54.54,0,0,0,0,.76l3.5,3.67a.94.94,0,0,1,.23.1l.83.53a1,1,0,0,1,.3,1.42,1.1,1.1,0,0,1-.44.39,1.93,1.93,0,0,0,.72.2.22.22,0,0,1,.22.19,13.2,13.2,0,0,0,1.29,3.29,3,3,0,0,0,2.74,1.47h.06a.24.24,0,0,1,.18.07l0,0h9.53A3.43,3.43,0,0,0,503.15,111.79Z" fill="#fff"/>
<path d="M511.42,88.47a10.45,10.45,0,0,0-9.32-5h-.53a10.45,10.45,0,0,0-9.32,5,9.16,9.16,0,0,0-.19,9.19,79.81,79.81,0,0,1,4.22,7.56,6,6,0,0,0,4.39,3.64,5.87,5.87,0,0,0,1.13.1h.07a5.94,5.94,0,0,0,1.13-.1,6,6,0,0,0,4.39-3.64,77.92,77.92,0,0,1,4.23-7.57A9.16,9.16,0,0,0,511.42,88.47Zm-17.55,8v-2a.25.25,0,0,1,.24-.25h1.46a4.37,4.37,0,0,1,4.37,4.37v3.19a.25.25,0,0,1-.25.25h-.25A5.57,5.57,0,0,1,493.87,96.46Zm10.83,8.37a2.65,2.65,0,0,1-2.65,2.64H502a2.64,2.64,0,0,1-2.64-2.64v-.18a.19.19,0,1,1,.38,0v.18a2.27,2.27,0,0,0,2.26,2.26h.05a2.26,2.26,0,0,0,2.26-2.26v-.18a.2.2,0,1,1,.39,0Zm5.1-8.37a5.58,5.58,0,0,1-5.57,5.57H504a.25.25,0,0,1-.25-.25V98.59a4.37,4.37,0,0,1,4.37-4.37h1.45a.25.25,0,0,1,.25.25Z" fill="#fff"/>
<path d="M491.67,108.37l-.82-.53a.54.54,0,0,0-.73.16.55.55,0,0,0-.08.41.49.49,0,0,0,.23.33l.83.53a.53.53,0,0,0,.72-.16A.52.52,0,0,0,491.67,108.37Z" fill="#fff"/>
</g>
<circle class="cta" cx="500" cy="100" r="36" fill="transparent" stroke="#fff" stroke-width="2" stroke-miterlimit="10"/>
<circle class="cta" cx="500" cy="100" r="36" fill="transparent" stroke="#fff" stroke-width="2" stroke-miterlimit="10"/>
<circle class="cta" cx="500" cy="100" r="36" fill="transparent" stroke="#fff" stroke-width="2" stroke-miterlimit="10"/>
</g>
<path d="M500,200c164.58,0,300,135.42,300,300S664.58,800,500,800,200,664.58,200,500a300,300,0,0,1,40.27-150.13" fill="none" stroke="#929292" stroke-width="12" stroke-miterlimit="10"/>
<path id="electricRing" d="M500,200c164.58,0,300,135.42,300,300S664.58,800,500,800,200,664.58,200,500a300,300,0,0,1,40.27-150.13" fill="none" stroke="#fff" stroke-width="12" stroke-miterlimit="10" filter="url(#glow)"/>
<!-- Ring Master Circles -->
<g id="gooCircles" fill="#8cbc08" filter="url(#alienGoo)">
<circle cx="500" cy="200" r="60" />
<circle cx="240" cy="350" r="60" />
<circle cx="240" cy="650" r="60" />
<circle cx="500" cy="800" r="60" />
<circle cx="760" cy="650" r="60" />
<circle cx="760" cy="350" r="60" />
<circle id="gooBlob" cx="500" cy="200" r="50" />
</g>
<text transform="translate(728 940)" font-size="18" fill="#fff" >What's your favorite goo color?</text>
<text transform="translate(500 16)" font-size="20" fill="#fff" text-anchor="middle" >Grab the handle and give it a spin.</text>
<!-- Swatch circles -->
<g class="swatches" fill="#fff">
<circle cx="750" cy="975" r="22" />
<circle cx="800" cy="975" r="22"/>
<circle cx="850" cy="975" r="22"/>
<circle cx="900" cy="975" r="22" />
<circle cx="950" cy="975" r="22" />
</g>
<text transform="translate(500 450)" text-anchor="middle" font-size="20" fill="#d8d8d8" >Highly unlikely, but possibly true</text>
<text transform="translate(500 490)" text-anchor="middle" font-size="40" fill="#d8d8d8">FACTS ABOUT ALIENS</text>
<g id="panelGoo" clip-path="url(#theClipPath)" filter="url(#gooDrip)" fill="#8cbc08">
<path d="M512.16,505.05c11.69,4.9,8.11,1.6,48.72,1.6s45.54,15.1,52.86,22.42,29.44,9,39.82-1.42c5.62-5.63,15.66-17.26,11.71-26.74-.13-.31-.28-.61-.44-.91H507.32C506.82,501.54,508,503.31,512.16,505.05Z" />
<path id="drip" d="M632.63,532.83c-12.69,0-6.48-23.18,0-23.18S645.32,532.83,632.63,532.83Z" />
</g>
<g id="clipPathReveal" clip-path="url(#theClipPath)">
<g id="factoids">
<g id="fact1">
<text transform="translate(350 550)" font-size="36" fill="#fff" >1. Top Secret</text>
<text transform="translate(350 590)" font-size="24" fill="#fff" >Blueprints for this gooey
<tspan x="0" y="32">demo are from the crash</tspan>
<tspan x="0" y="64">site in Roswell, NM.</tspan>
</text>
</g>
<g id="fact2" transform="translate(0 180)">
<text transform="translate(350 550)" font-size="36" fill="#fff" >2. Fuel Source</text>
<text transform="translate(350 600)" font-size="24" fill="#fff" >All UFOs are powered
<tspan x="0" y="32">by Diet Dr. Pepper.</tspan>
</text>
</g>
<g id="fact3" transform="translate(0 360)">
<text transform="translate(350 550)" font-size="36" fill="#fff" >3. Coders</text>
<text transform="translate(350 590)" font-size="24" fill="#fff" >There are 739 CodePen
<tspan x="0" y="32">accounts known to</tspan>
<tspan x="0" y="64">be run by aliens.</tspan>
</text>
</g>
<g id="fact4" transform="translate(0 540)">
<text transform="translate(350 550)" font-size="36" fill="#fff" >4. Hollywood</text>
<text transform="translate(350 590)" font-size="24" fill="#fff" >Every sci-fi alien
<tspan x="0" y="32">movie is actually</tspan>
<tspan x="0" y="64">a true documentary.</tspan>
</text>
</g>
<g id="fact5" transform="translate(0 720)">
<text transform="translate(350 550)" font-size="36" fill="#fff" >5. Abductions</text>
<text transform="translate(350 590)" font-size="24" fill="#fff" >97% of all abductions
<tspan x="0" y="32">happen within a 3 mile</tspan>
<tspan x="0" y="64">radius of a Denny's.</tspan>
</text>
</g>
<g id="fact6" transform="translate(0 900)">
<text transform="translate(350 550)" font-size="36" fill="#fff" >6. Animations</text>
<text transform="translate(350 590)" font-size="24" fill="#fff" >All aliens animate
<tspan x="0" y="32">with the GreenSock</tspan>
<tspan x="0" y="64">Animation Platform.</tspan>
</text>
</g>
</g>
</g>
<g id="icons">
<g id="camera">
<path d="M482.57,816.24A2.74,2.74,0,0,0,485.3,819l38.59,0a2.73,2.73,0,0,0,2.73-2.74l0-23.48a2.74,2.74,0,0,0-2.73-2.74l-38.59,0a2.73,2.73,0,0,0-2.73,2.73Z" fill="#fff"/>
<polygon points="480.55 796.16 466.57 787.67 466.21 819.84 480.45 811.63 480.55 796.16" fill="#fff"/>
<path d="M481.25,776.76a11.12,11.12,0,1,0,11.12-11.1A11.13,11.13,0,0,0,481.25,776.76Z" fill="#fff"/>
<path d="M505.77,776.78a11.12,11.12,0,1,0,11.13-11.1A11.13,11.13,0,0,0,505.77,776.78Z" fill="#fff"/>
</g>
<g id="abduction">
<path d="M270.3,634.27c-6,3.85-21.06,8.77-32.24,8.87h-.37c-11.22,0-26.57-5-32.6-8.88h0l-.69,4.51a61.57,61.57,0,0,0,16.31,9.85l-9.82,20.61.22.2c.33.32,8.48,7.8,26.64,7.8h.32c17.93-.09,26.87-7.71,27-7.79l.23-.2-9.95-20.87a61.45,61.45,0,0,0,15.7-9.6Zm-58.52,8.62a2.06,2.06,0,1,1,2.06-2A2.05,2.05,0,0,1,211.78,642.89Zm40-.29a2.58,2.58,0,1,1-2.58,2.58A2.58,2.58,0,0,1,251.81,642.6Zm-14.12,2.58a2.59,2.59,0,1,1-2.58,2.58A2.58,2.58,0,0,1,237.69,645.18Zm-13.82-2.58a2.58,2.58,0,1,1-2.58,2.58A2.59,2.59,0,0,1,223.87,642.6ZM264.25,669c-1.51,1.17-10.19,7.32-26.22,7.4h-.29c-16.2,0-24.45-6.21-25.87-7.39l9.41-19.74a42.73,42.73,0,0,0,33.45-.24Zm-1.47-25.88a2.06,2.06,0,1,1,2.06-2.06A2.05,2.05,0,0,1,262.78,643.15Z" fill="#fff"/>
<path d="M255.84,632.35a15.74,15.74,0,0,1-.45,1.92A48,48,0,0,1,243,637.73a37.26,37.26,0,0,1-5.33.38A45.83,45.83,0,0,1,220,634.27a17.63,17.63,0,0,1-.69-4c-5.94.38-11.23,1.25-14.23,3.18h0c6,3.89,21.38,8.88,32.6,8.88h.37c11.18-.1,26.27-5,32.24-8.87-3-1.93-8.29-2.8-14.23-3.18A17.71,17.71,0,0,1,255.84,632.35Z" fill="#fff"/>
<path d="M244.15,612.24a17.55,17.55,0,0,0-7.31-1.18l-.71,0-.56.06-.95.14-.44.09-.67.14a12.64,12.64,0,0,0-1.32.38c-.33.1-.64.21-1,.33a18.09,18.09,0,0,0-11.56,16.89c0,.38,0,.75,0,1.12a17,17,0,0,0,.57,3.53l.05.19.18.07a44.9,44.9,0,0,0,17.18,3.66,37.6,37.6,0,0,0,5.28-.37A47.14,47.14,0,0,0,254.88,634l.18-.07.05-.19c.13-.48.24-1,.34-1.5a19.12,19.12,0,0,0,.22-2v-.16c0-.32,0-.64,0-1A18.18,18.18,0,0,0,244.15,612.24Zm10.72,17.84v.12a15.35,15.35,0,0,1-.21,1.94q-.12.65-.27,1.23a46.5,46.5,0,0,1-11.52,3.16,37.55,37.55,0,0,1-5.17.36A43.89,43.89,0,0,1,221,633.37a16.26,16.26,0,0,1-.49-3.17c0-.35,0-.71,0-1.07A17.25,17.25,0,0,1,225,617.42a17.07,17.07,0,0,1,6.48-4.42c.3-.12.6-.22.92-.32a11.06,11.06,0,0,1,1.25-.36l.65-.14.41-.08.92-.13.53-.06.67,0a16.75,16.75,0,0,1,7,1.12,17.38,17.38,0,0,1,11,16.14C254.91,629.44,254.89,629.74,254.87,630.08Z" fill="#fff"/>
<g id="body">
<path d="M240.05,669a3.25,3.25,0,0,1-4.51-.89h0a3.24,3.24,0,0,1,.89-4.5l4-2.72a3.24,3.24,0,0,1,4.5.89h0a3.25,3.25,0,0,1-.89,4.51Z" fill="#fff"/>
<path d="M249,662a2.44,2.44,0,1,1,.67-3.39A2.44,2.44,0,0,1,249,662Z" fill="#fff"/>
<rect x="236.93" y="656.56" width="2.58" height="7.74" rx="0.97" ry="0.97" transform="translate(-455.83 766.27) rotate(-78.84)" fill="#fff"/>
<rect x="239.78" y="667.23" width="7.74" height="2.58" rx="0.97" ry="0.97" transform="translate(-459.4 778.13) rotate(-78.84)" fill="#fff"/>
<rect x="230.22" y="668.72" width="9.75" height="3.25" rx="1.22" ry="1.22" transform="translate(-382.48 319.29) rotate(-41.06)" fill="#fff"/>
<rect x="228.41" y="666.03" width="9.75" height="3.25" rx="1.22" ry="1.22" transform="translate(-274.57 175.45) rotate(-26.64)" fill="#fff"/>
</g>
</g>
<g id="soda">
<polygon points="771.09 328.5 767.04 328.5 762.99 328.5 758.95 328.5 754.9 328.5 750.86 328.5 746.81 328.5 742.76 328.5 743.35 334.55 743.39 334.9 744.01 341.29 744.64 347.69 745.26 354.08 745.76 359.14 745.89 360.48 746.51 366.87 747.14 373.27 747.76 379.66 750.56 379.66 753.36 379.66 756.15 379.66 758.95 379.66 761.74 379.66 764.54 379.66 767.33 379.66 770.13 379.66 770.48 376.12 770.75 373.27 771.38 366.87 772.01 360.48 772.58 354.62 772.63 354.08 773.26 347.69 773.88 341.29 774.51 334.9 775.13 328.5 771.09 328.5" fill="#fff"/>
<rect x="741.43" y="325.48" width="35.04" height="2.21" fill="#fff"/>
<path d="M760,323.9h-2v-8.15a6.34,6.34,0,0,1,3.25-5.33c1.45-.93,4.14-2.36,4.25-2.42l.94,1.77s-2.73,1.45-4.11,2.34a4.46,4.46,0,0,0-2.33,3.64Z" fill="#fff"/>
</g>
<g id="computer">
<path d="M787.83,617.62H734a6.18,6.18,0,0,0-6.17,6.17v35.66a6.18,6.18,0,0,0,6.17,6.17h53.81a6.18,6.18,0,0,0,6.17-6.17V623.79A6.18,6.18,0,0,0,787.83,617.62ZM760.93,662a3.09,3.09,0,1,1,3.08-3.09A3.09,3.09,0,0,1,760.93,662Zm28-10.51a1.66,1.66,0,0,1-1.66,1.66H734.56a1.66,1.66,0,0,1-1.66-1.66V624.33a1.66,1.66,0,0,1,1.66-1.67h52.73a1.66,1.66,0,0,1,1.66,1.67Z" fill="#fff"/>
<path d="M772.33,675.46h-2.62a.76.76,0,0,0,0-.21,1.23,1.23,0,0,0,0-.2l-1-6H753.1l-1,6.1a.82.82,0,0,0,0,.35h-2.62a2.23,2.23,0,0,0-2.23,2.23V679a.87.87,0,0,0,.87.88h25.53a.87.87,0,0,0,.87-.88v-1.32A2.23,2.23,0,0,0,772.33,675.46Z" fill="#fff"/>
</g>
<path id="mouse" d="M264.8,314.45c-3.24-3.53-10-5.58-18.28.56-2.55,1.87-5.1,2.42-7,1.49s-2.8-3-2.8-5.89c0-3.48-5.28-3.48-5.28,0,0,4.84,2.11,8.75,5.72,10.55s8.26,1.18,12.49-1.93c4.48-3.29,8.83-3.78,11.19-1.24,1.93,2.17,2.24,6.52-1.74,10.86l-5.91,6.33c-8.45-5.83-22.44-2.54-33.25,8.26-8.33,8.31-16.6,25.38-6.59,35.37,8.08,8.07,23.62,5.15,35.37-6.58,10.88-10.86,14.17-25,8.2-33.39l6.1-6.45C269,325.87,268.4,318.49,264.8,314.45Zm-14.55,25L247.76,342a3.32,3.32,0,0,0-3,.87l-4.54,4.53a3.23,3.23,0,0,0-.81,3l-2.92,2.85a53,53,0,0,1-7.52-10.42C236.64,337.54,245.21,336.11,250.25,339.46Zm-8.39,13.41a3.42,3.42,0,0,0,3-.87l4.54-4.53a3.24,3.24,0,0,0,.81-3l2.49-2.42a11.62,11.62,0,0,1,1.86,6.64c0,4.47-1.86,9.74-5.22,14.58a50.11,50.11,0,0,1-10.44-7.51Zm-24.74,22.22c-8.46-8.38,1.86-24.14,8.95-30a56,56,0,0,0,21.13,21.1C241.17,373.29,225.38,383.34,217.12,375.09Z" fill="#f6f1eb"/>
<path id="ufo" d="M485,224.46l7,6.62c2.88,2.08,17.1,2.08,20,0l7-6.59c9-2.08,15-5.76,15-10,0-3.69-4.64-7-11.88-9.13v-4.76a20,20,0,0,0-4.73-12.95,6.42,6.42,0,0,1,.07-1,5.33,5.33,0,0,1,2.15-3.44,5.52,5.52,0,0,1,1.95-.87,4.74,4.74,0,1,0-1-4.23,9.8,9.8,0,0,0-3.51,1.56,9.55,9.55,0,0,0-3.43,4.49,20.06,20.06,0,0,0-23.29,0,9.57,9.57,0,0,0-3.42-4.46,9.8,9.8,0,0,0-3.51-1.56,4.72,4.72,0,1,0-1,4.24,5.29,5.29,0,0,1,4.1,4.3,5.79,5.79,0,0,1,.07.92,20,20,0,0,0-4.77,13v4.76c-7.23,2.16-11.85,5.44-11.84,9.13C470,218.71,476,222.38,485,224.46ZM487.8,204v-3.36a14.18,14.18,0,1,1,28.36,0v6.93c-2.23,1.26-7.43,2.42-14.18,2.42s-12-1.16-14.18-2.42Zm16.78,15.21c0,.56-1,1-2.31,1s-2.31-.46-2.31-1c0-.34.39-.65,1-.83a4.39,4.39,0,0,1,1.33-.19,4.49,4.49,0,0,1,1.33.19C504.19,218.56,504.58,218.87,504.58,219.21Zm9.2-1.81c0-.56,1-1,2.31-1s2.31.45,2.31,1-.71.86-1.67,1a4.4,4.4,0,0,1-.64,0,4.54,4.54,0,0,1-.65,0C514.48,218.26,513.78,217.87,513.78,217.4Zm-27.64,0c0-.56,1-1,2.3-1s2.31.46,2.31,1-.68.84-1.61,1a4.86,4.86,0,0,1-1.39,0C486.82,218.25,486.14,217.86,486.14,217.41Zm39-6.6c1.28,0,2.31.46,2.31,1s-1,1-2.31,1-2.31-.45-2.31-1S523.87,210.81,525.14,210.81Zm-45.75,0c1.27,0,2.31.45,2.31,1s-1,1-2.31,1-2.31-.45-2.31-1S478.11,210.82,479.39,210.82Z" fill="#fff"/>
</g>
<image id="sexyAlien" xlink:href="https://s3-us-west-2.amazonaws.com/s.cdpn.io/314556/sexyAlien.png" x="367" y="272" width="261" height="160" />
</svg>
#demo {
font-family: "Roboto", sans-serif;
font-weight: 700;
width: 90%;
height: 90%;
max-width: 90%;
max-height: 90%;
}
body {
height: 100vh;
width: 100%;
padding: 0;
margin: 0;
overflow: hidden;
display: flex;
align-content: center;
flex-direction: column;
align-items: center;
justify-content: center;
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/314556/alienPlanet.jpg")
center bottom no-repeat;
background-size: cover;
}
#spinner {
cursor: move;
}
.swatches circle {
cursor: pointer;
}
var colorArray = ["#8cbc08", "#439899", "#7e4ce4", "#c77b19", "#cc50db"];
var flicker = RoughEase.ease.config({ template:Power0.easeNone, strength:1, points:20, taper:"none", randomize: true, clamp: false});
var swatches = document.querySelectorAll(".swatches circle");
var ringAnim = new TimelineMax({repeat:-1, repeatDelay:1});
var dripAnim = new TimelineMax({repeat:-1, repeatDelay:1.6});
// inital setup
TweenMax.set("#electricRing", {drawSVG:0});
TweenMax.set("#spinner, #gooBlob", { svgOrigin: "500 500" });
TweenMax.set("#gooCircles circle, #panelGoo path", {attr: {fill:colorArray[0]} });
//Apply initial swatch colors and add listeners
for (i = 0; i < swatches.length; i++) {
TweenMax.set(swatches[i], { attr:{fill:colorArray[i]} });
swatches[i].index = i;
swatches[i].addEventListener("click", changeGoo);
}
// repeating tweens
TweenMax.to("#electricRing", 0.8, {opacity:0.4, yoyo:true, repeat:-1, ease:flicker});
TweenMax.to("#sexyAlien", 4, {y:-24, rotation:0.1, ease:Power2.easeInOut, repeat:-1, yoyo:true});
//Timelines
ringAnim.staggerFromTo(".cta", 1, {attr:{r:36}, opacity:0}, {attr:{r:44}, opacity:0.5, ease:Power2.easeIn}, 0.35);
ringAnim.staggerTo(".cta", 1, {attr:{r:54}, opacity:0, ease:Power2.easeOut}, 0.35, 1);
dripAnim.to("#drip", 3.5, {y:36, ease:Power1.easeIn});
dripAnim.to("#drip", 0.45, {y:500, ease:Power1.easeIn});
//Update goo color on swatch click
function changeGoo() {
TweenMax.to("#gooCircles circle, #panelGoo path", 0.9, {attr: {fill:colorArray[this.index], ease:Linear.easeNone} });
}
// Create rotational dragger
Draggable.create("#spinner", {
type: "rotation",
bounds: {
minRotation:0,
maxRotation:300
},
snap:[0, 60, 120, 180, 240, 300],
throwProps:true,
onPress: alienPress,
onRelease: alienRelease,
onDrag: alienUpdate,
onThrowUpdate: alienUpdate
});
//Draggable handlers
function alienUpdate() {
TweenMax.set("#gooBlob", {rotation:this.rotation});
TweenMax.set("#factoids", {y:-(this.rotation * 3)});
TweenMax.set("#electricRing", {drawSVG:"0% " + this.rotation/3 + "%"});
}
function alienPress() {
ringAnim.seek(0).pause();
}
function alienRelease() {
ringAnim.play();
}
Also see: Tab Triggers