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 class="dude" viewBox="0 0 2800 1000" >
<g class="trash-dump" transform="translate(-150,0)">
<circle class="trash" opacity="0" fill="#73441C" cx="1490" cy="859" r="75"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1606" cy="887" r="97"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1720" cy="778" r="110"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1831" cy="893" r="103"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1933" cy="974" r="81"></circle>
<g class="trash__bottle" opacity="0">
<path fill="#096551" d="M1422 841c-5,3 -6,9 -4,14l54 92c2,5 9,7 14,4l12 -8 -85 -147 -5 3c-2,1 -2,4 -1,6l19 34 -4 2z"/>
<path fill="#0A7864" d="M1447 827c5,-3 11,-2 14,3l53 92c3,5 1,12 -4,15l-12 7 -85 -147 5 -3c2,-2 4,-1 6,1l19 34 4 -2z"/>
<path fill="#E26020" d="M1407 808l-3 -5c-1,-2 -1,-4 1,-5l15 -9c1,-1 3,0 4,2l4 5c1,2 0,4 -1,5l-16 9c-1,1 -3,0 -4,-2z"/>
<path fill="#CF5A21" d="M1412 794l-8 5c-1,0 -2,2 -1,4l3 6c1,1 3,2 5,1l7 -4 -6 -12z"/>
</g>
<circle class="trash" opacity="0" fill="#99561E" cx="1853" cy="968" r="104"></circle>
<circle class="trash" opacity="0" fill="#99561E" cx="1773" cy="916" r="109"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1461" cy="974" r="98"></circle>
<circle class="trash" opacity="0" fill="#884F1D" cx="1547" cy="951" r="81"></circle>
<circle class="trash" opacity="0" fill="#99561E" cx="1646" cy="974" r="69"></circle>
<circle class="trash" opacity="0" fill="#73441C" cx="1398" cy="974" r="87"></circle>
<circle class="trash" opacity="0" fill="#99561E" cx="1640" cy="939" r="69"></circle>
<g class="trash__bottle" opacity="0">
<path fill="#096551" d="M1906 960c0,-7 -6,-13 -13,-13l-129 0c-7,0 -12,6 -12,13l0 18 206 0 0 -8c0,-3 -2,-5 -5,-5l-47 0 0 -5z"/>
<path fill="#0A7864" d="M1906 994c0,7 -6,13 -13,13l-129 0c-7,0 -12,-6 -12,-13l0 -18 206 0 0 8c0,3 -2,5 -5,5l-47 0 0 5z"/>
<path fill="#E26020" d="M1949 963l8 0c3,0 4,2 4,4l0 21c0,3 -1,4 -4,4l-8 0c-2,0 -4,-1 -4,-4l0 -21c0,-2 2,-4 4,-4l0 0z"/>
<path fill="#CF5A21" d="M1961 977l0 -11c0,-2 -1,-4 -4,-4l-8 0c-2,0 -4,2 -4,4l0 11 16 0z"/>
</g>
</g>
<g class="truck" transform="translate(-1500, 11)" >
<polygon fill="#096551" points="216,850 561,850 561,759 216,759 "/>
<path fill="#0A7864" d="M436 595l96 0c16,0 29,14 29,30l0 137 -345 0c2,-13 14,-22 28,-24l145 -22c1,0 1,0 2,0 1,0 1,0 2,0l13 -91c3,-16 14,-30 30,-30l0 0z"/>
<path fill="#DDECFA" d="M451 616l42 0c15,0 27,12 27,27l0 60c0,0 0,0 0,0 0,15 -12,27 -27,27l-47 0c-14,0 -33,-11 -30,-31l7 -56c3,-15 13,-27 28,-27z"/>
<g class="truck-pump">
<rect class="truck-pump__bottom" fill="#1F1B20" x="850" y="750" width="67" height="128" />
<polygon fill="#1F1B20" points="834,811 934,811 934,727 834,727 "/>
</g>
<g class="truck-body">
<path fill="#EF7A1B" d="M1041 427c0,-3 -3,-6 -6,-6l-484 28c-3,0 -6,3 -6,6l0 389c0,3 3,6 6,6l557 0c3,0 5,-3 5,-6l-72 -417z"/>
<path fill="none" stroke="#da5500" stroke-width="15" d="M597 488l32 0m207 11c0,-6 5,-11 12,-11m-12 312l0 -301m12 312c-7,0 -12,-5 -12,-11m43 11l-31 0m42 -11c0,6 -5,11 -11,11m11 -312l0 301m-11 -312c6,0 11,5 11,11m-42 -11l31 0m-126 11c0,-6 5,-11 11,-11m-11 312l0 -301m11 312c-6,0 -11,-5 -11,-11m43 11l-32 0m43 -11c0,6 -5,11 -11,11m11 -312l0 301m-11 -312c6,0 11,5 11,11m-43 -11l32 0m-127 11c0,-6 5,-11 12,-11m-12 312l0 -301m12 312c-7,0 -12,-5 -12,-11m43 11l-31 0m42 -11c0,6 -5,11 -11,11m11 -312l0 301m-11 -312c6,0 11,5 11,11m-42 -11l31 0m-126 11c0,-6 5,-11 11,-11m-11 312l0 -301m11 312c-6,0 -11,-5 -11,-11m43 11l-32 0m43 -11c0,6 -5,11 -11,11m11 -312l0 301m-11 -312c6,0 11,5 11,11"/>
<path fill="#E26020" d="M1041 427c0,-3 -3,-6 -6,-6l-77 5c8,43 74,424 77,424l73 0c3,0 5,-3 5,-6l-72 -417z"/>
<path fill="#C94A22" fill-opacity="0.5" d="M545 644l0 200c0,3 3,6 6,6l557 0c3,0 5,-3 5,-6l-35 -200 -533 0z"/>
</g>
<path fill="#1F1B20" d="M1049 849c-3,0 -32,-39 -81,-39l0 0c-32,0 -60,15 -79,39l-445 0c-18,-23 -47,-38 -78,-38l0 0c-32,0 -60,15 -79,38l-68 0c-10,0 -19,9 -19,19l0 29c0,10 9,19 19,19 277,0 554,0 831,0 12,0 18,-7 18,-19 1,-10 1,-19 1,-29 0,-10 -9,-19 -20,-19l0 0z"/>
<g class="wheel">
<path fill="#656463" d="M445 911c0,-44 -36,-79 -79,-79 -44,0 -80,35 -80,79 0,44 36,79 80,79 43,0 79,-35 79,-79z"/>
<path fill="#4A4A4A" d="M366 832c43,0 79,35 79,79 0,44 -36,79 -79,79l0 -158z M397 911c0,-18 -14,-32 -31,-32 -18,0 -32,14 -32,32 0,17 14,32 32,32 17,0 31,-15 31,-32z"/>
<path fill="#2D2E2E" d="M366 879c17,0 31,14 31,32 0,17 -14,32 -31,32l0 -64z"/>
</g>
<g class="wheel">
<path fill="#656463" d="M1045 911c0,-44 -36,-79 -80,-79 -43,0 -79,35 -79,79 0,44 36,79 79,79 44,0 80,-35 80,-79z"/>
<path fill="#4A4A4A" d="M965 832c44,0 80,35 80,79 0,44 -36,79 -80,79l0 -158z M997 911c0,-18 -14,-32 -32,-32 -17,0 -31,14 -31,32 0,17 14,32 31,32 18,0 32,-15 32,-32z"/>
<path fill="#2D2E2E" d="M965 879c18,0 32,14 32,32 0,17 -14,32 -32,32l0 -64z"/>
</g>
</g>
<g class="dude-body" transform="translate(0,20)">
<rect class="leg" fill="#a5a6a6" x="1982" y="900" width="17" height="70" rx="17" ry="7" />
<g class="pilus" fill="none" stroke="#111" stroke-width="4" >
<line x1="2086" y1="642" x2="1905" y2="642" />
<line x1="2086" y1="663" x2="1905" y2="663" />
<line x1="2086" y1="703" x2="2062" y2="703" />
<line x1="2086" y1="683" x2="1905" y2="683" />
<line x1="2086" y1="743" x2="2065" y2="743" />
<line x1="2086" y1="764" x2="2065" y2="764" />
<line x1="2086" y1="804" x2="2065" y2="804" />
<line x1="2086" y1="723" x2="2065" y2="723" />
<line x1="2086" y1="784" x2="2065" y2="784" />
<line x1="2086" y1="824" x2="2065" y2="824" />
<line x1="2086" y1="844" x2="2065" y2="844" />
<line x1="2086" y1="622" x2="1905" y2="622" />
<line x1="2086" y1="865" x2="2065" y2="863" />
<line x1="2076" y1="577" x2="2052" y2="590" />
<line x1="2061" y1="557" x2="2042" y2="578" />
<line x1="2043" y1="543" x2="2028" y2="567" />
<line x1="2020" y1="534" x2="2013" y2="562" />
<line x1="1997" y1="531" x2="1998" y2="561" />
<line x1="1973" y1="534" x2="1981" y2="563" />
<line x1="1953" y1="543" x2="1967" y2="567" />
<line x1="1934" y1="557" x2="1954" y2="577" />
<line x1="1920" y1="575" x2="1943" y2="589" />
<line x1="1911" y1="597" x2="1938" y2="604" />
<line x1="2086" y1="596" x2="2059" y2="604" />
<line x1="1918" y1="910" x2="1942" y2="896" />
<line x1="1934" y1="929" x2="1952" y2="909" />
<line x1="1951" y1="943" x2="1967" y2="919" />
<line x1="1974" y1="953" x2="1982" y2="925" />
<line x1="1998" y1="955" x2="1997" y2="925" />
<line x1="2021" y1="952" x2="2013" y2="923" />
<line x1="2041" y1="944" x2="2027" y2="919" />
<line x1="2060" y1="929" x2="2040" y2="910" />
<line x1="2075" y1="911" x2="2051" y2="897" />
<line x1="1908" y1="890" x2="1936" y2="883" />
<line x1="2086" y1="890" x2="2059" y2="883" />
</g>
<g>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
<circle class="fart" fill="#58936b" cx="2055" cy="864" r="0"/>
</g>
<path class="head" fill="#ccc" d="M2063 732l-135 0 0 -107c0,-37 30,-68 67,-68 38,0 68,31 68,68l0 107z"/>
<path class="jaw" fill="#aaa" d=" M 2063 728 l 0 136 a 67 67 0 0 1 -134, 0 l -18 -154 48 5 q 106.3, 8.5, 106.3, 8.5 l 0 0z"/>
<path class="eye-white" fill="#FEFEFE" d="M1977 591c-19,0 -34,16 -34,35l0 33c0,19 15,34 34,34l0 0c19,0 34,-15 34,-34l0 -33c0,-19 -15,-35 -34,-35l0 0z"/>
<circle class="pupil" fill="#111" cx="1960" cy="662" r="17"></circle>
<path clip-path="url(#eye-lids-clip)" class="eyelid" fill="#aaa" d="M2012 623c0,-20 -16,-35 -36,-35 -20,0 -36,15 -36,35l0 39c0,20 16,35 36,35 20,0 36,-15 36,-35l0 -39z"/>
<clipPath id="eye-lids-clip">
<rect class="eyelid-top" x="1925" width="101" y="588" height="65"/>
<rect class="eyelid-bottom" x="1925" width="101" y="699" height="35"/>
</clipPath>
<g class="spots" fill="#3A3B3A" fill-opacity="0.5" >
<circle cx="2049" cy="865" r="9" />
<circle cx="2038" cy="615" r="9" />
<circle cx="1977" cy="904" r="7" />
<circle cx="2052" cy="824" r="7" />
</g>
<rect class="leg" fill="#aaa" x="2000" y="900" width="17" height="70" rx="17" ry="7" />
</g>
</svg>
body {
font-family: sans-serif;
width: 100%;
height: 100vh;
display: flex;
justify-content: space-around;
}
svg {
width: 100%;
max-height: 80%;
max-width: 400px;
}
gsap.registerPlugin(MotionPathPlugin);
// selectors
const dude = document.querySelector('svg');
const truck = dude.querySelector('.truck');
const truckWheel = dude.querySelectorAll('.wheel');
const truckBody = dude.querySelector('.truck-body');
const truckPump = dude.querySelector('.truck-pump');
const truckPumpBottom = dude.querySelector('.truck-pump__bottom');
const farts = Array.from(dude.querySelectorAll('.fart'));
const legs = Array.from(dude.querySelectorAll('.leg'));
const trash = Array.from(dude.querySelectorAll('.trash'));
const trashSorted = Array.from(dude.querySelectorAll('.trash'))
.sort((a, b) => (b.getAttribute('cx') - a.getAttribute('cx')));
const bottles = Array.from(dude.querySelectorAll('.trash__bottle'));
const dudeBody = dude.querySelector('.dude-body');
const jaw = dude.querySelector('.jaw');
const head = dude.querySelector('.head');
const pupil = dude.querySelector('.pupil');
const eyelid = {
top: dude.querySelector('.eyelid-top'),
bottom: dude.querySelector('.eyelid-bottom'),
};
let walkingFlag = false;
dudeTl = new gsap.timeline({
repeat: -1,
})
.addLabel('truck-turn', 2)
.addLabel('trash-dump', 2.2)
.addLabel('truck-turn-back', 2.7)
.addLabel('truck-leave-scene', 3.4)
.addLabel('dude-mouth-open', 2.5)
.addLabel('dude-goes-left', 2.8)
.addLabel('dude-mouth-close', 4.35)
.addLabel('dude-goes-right', 5.2)
.addLabel('fart', 6.7)
.addLabel('loop', 8.8)
// TRUCK related animations
// (come, unload, go back)
.to(truck, {
duration: 2,
x: 20,
ease: 'power2.out'
}, 0)
.to(truckWheel, {
duration: 2,
rotation: 700,
transformOrigin: 'center center',
ease: 'power2.out'
}, 0)
.to(truckBody, {
duration: 0.5,
y: 37,
rotation: 30,
transformOrigin: 'bottom right'
}, 'truck-turn')
.from(truckPump, {
duration: 0.5,
y: 83
}, 'truck-turn')
.from(truckPumpBottom, {
duration: 0.5,
height: 83
}, 'truck-turn')
.to(truckBody, {
duration: 0.55,
y: 0,
x: 0,
rotation: 0,
transformOrigin: 'bottom right'
}, 'truck-turn-back')
.from(truckPump, {
duration: 0.55,
y: 0
}, 'truck-turn-back')
.from(truckPumpBottom, {
duration: 0.55,
height: 128
}, 'truck-turn-back')
.to(truck, {
duration: 1.5,
x: -1500,
ease: 'power2.in'
}, 'truck-leave-scene')
.to(truckWheel, {
duration: 1.5,
rotation: 0,
ease: 'power2.in'
}, 'truck-leave-scene')
// TRASH related animations
// (dump, then been eaten)
.set(trash, {
attr: { 'opacity': 1 }
}, 'trash-dump')
.from(trash.slice(Math.ceil(trash.length / 2), trash.length), {
duration: 0.5,
attr: { 'cx': 1158, 'cy': 740 },
ease: 'power1.in'
}, 'trash-dump-=0.15')
.from(trash.slice(0, Math.floor(trash.length / 2)), {
duration: 0.5,
attr: { 'cx': 1158, 'cy': 740 },
ease: 'power1.in'
}, 'trash-dump')
.set([trash, bottles], {
attr: { 'opacity': 1 }
}, 'trash-dump+=0.1')
.from(bottles[0], {
duration: 0.6,
x: -140,
y: -50
}, 'trash-dump+=0.1')
.from(bottles[1], {
duration: 0.4,
x: -500,
y: -70,
rotation: -90
}, 'trash-dump+=0.1')
.to(bottles[1], {
duration: 0.4,
x: -100,
y: -150,
scale: 0.5,
attr: { 'opacity' : 0 },
transformOrigin: 'center center'
}, 'dude-goes-left+=0.3')
.to(bottles[0], {
duration: 0.4,
x: 100,
scale: 0.5,
attr: { 'opacity' : 0 },
transformOrigin: 'center center'
}, 'dude-goes-left+=0.95');
trashSorted.forEach(function (t, idx) {
dudeTl
.to(t, 0.3, {
attr: {'r': 65, 'cy': 827}
}, 'dude-goes-left+=' + idx * (idx < trashSorted.length - 3 ? 0.1 : 0.11))
.to(t, 0.1, {
attr: {'r': 50, 'cy': (870 - idx * 3)}
}, 'dude-goes-left+=' + (idx * 0.11 + 0.45))
.to(t, 0.05, {
attr: {'opacity': 0}
}, 'dude-goes-left+=' + (idx * 0.11 + 0.5))
});
// DUDE related animations
// (walking, eating)
const legsAnimation = gsap.timeline({
paused: true,
onComplete: () => {
if (walkingFlag) legsAnimation.play(0);
}
});
legs.forEach(function (l, idx) {
legsAnimation
.to(l, {
duration: 0.1,
rotation: idx ? -9 : 9
}, 0)
.to(l, {
duration: 0.1,
rotation: idx ? 9 : -9
}, 0.1);
});
dudeTl
.to(dudeBody, {
duration: 1.7,
x: -745,
ease: 'none',
onStart: function () {
legsAnimation.play(0);
walkingFlag = true;
},
onComplete: function () {
walkingFlag = false;
}
}, 'dude-goes-left')
.to(dudeBody, 1, {
x: 0,
ease: 'none',
onStart: function () {
legsAnimation.play(0);
walkingFlag = true;
},
onComplete: function () {
walkingFlag = false;
}
}, 'dude-goes-right');
const headStates = {
open: 'M2063 688l-135 40 0 -103c0,-37 30,-68 67,-68 38,0 68,31 68,68l0 63z',
close: 'M2063 732l-135 0 0 -107c0,-37 30,-68 67,-68 38,0 68,31 68,68l0 107z'
};
const jawStates = {
open: ' M 2063 688 l 0 176 a 67 67 0 0 1 -134, 0 l 0 0 l 48 0 q 61.2, -6.9, 61.2, -67.5 l 0 -101 z',
close: ' M 2063 728 l 0 136 a 67 67 0 0 1 -134, 0 l -18 -154 48 5 q 106.3, 8.5, 106.3, 8.5 l 0 0z',
fart: ' M 2063 715 l 0 149 a 67 67 0 0 1 -134, 0 l -14 -132 l 49 -6 q 52.7, -5.9, 52.7, -5.9 l 0 0z'
};
dudeTl
.to(jaw, {
duration: 0.4,
attr: { 'd' : jawStates.open },
ease: 'none'
}, 'dude-mouth-open')
.to(head, {
duration: 0.4,
attr: { 'd' : headStates.open },
ease: 'none'
}, 'dude-mouth-open')
.to(head, {
duration: 0.35,
attr: { 'd' : headStates.close },
ease: 'none'
}, 'dude-mouth-close')
.to(jaw, {
duration: 0.35,
attr: { 'd' : jawStates.close },
ease: 'none'
}, 'dude-mouth-close')
.to(jaw, {
duration: 0.5,
scaleX: 1.2,
transformOrigin: '100% 50%',
ease: 'none'
}, 'dude-mouth-close-=0.3')
.to(jaw, {
duration: 0.15,
scaleX: 1,
ease: 'none'
}, 'dude-mouth-close+=0.2')
.to(eyelid.top, {
duration: 0.2,
y: -17,
ease: 'none'
}, 'dude-mouth-close+=0.15')
.to(eyelid.bottom, {
duration: 0.2,
y: -19,
ease: 'none'
}, 'dude-mouth-close+=0.25')
.to(jaw, {
duration: 0.6,
attr: { 'd' : jawStates.fart }
}, 'fart+=0.1')
.to(eyelid.top, {
duration: 0.6,
y: -15
}, 'fart+=0.1')
.to(eyelid.bottom, {
duration: 0.6,
y: -38
}, 'fart+=0.1')
.to(pupil, {
duration: 0.5,
y: -15,
ease: 'none'
}, 'fart+=0.2')
.to(jaw, {
duration: 0.4,
attr: { 'd' : jawStates.close },
ease: 'none'
}, 'loop')
.to(head, {
duration: 0.4,
attr: { 'd' : headStates.close },
ease: 'none'
}, 'loop')
.to([eyelid.top, eyelid.bottom, pupil], {
duration: 0.3,
y: 0,
ease: 'none'
}, 'loop+=0.1');
// FART (as simple as is it)
farts.forEach(function (f) {
const randStart = 0.5 + Math.random();
const randDur = Math.random() + 3;
dudeTl
.set(f, {
attr: { 'opacity' : Math.random() * 0.5 }
}, 'fart+=' + randStart)
.to(f, {
duration: randDur,
motionPath: {
path: [{
x: 0, y: 0
}, {
x: 80, y: -50
}, {
x: 120 + Math.random() * 300,
y: -50 - Math.random() * 200
}, {
x: 120 + Math.random() * 600,
y: -700 - Math.random() * 200
}]
}
}, 'fart+=' + randStart)
.to(f, {
duration: randDur * 0.3,
attr: {
'r' : 50 + Math.random() * 30
}
}, 'fart+=' + randStart)
.to(f, {
duration: randDur * 0.7,
attr: {
'r' : 0,
'opacity' : 0
}
}, '>')
});
Also see: Tab Triggers