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.
<div id="wrap">
<svg id="path" width="1921" height="8040" viewBox="0 0 1921 8040" fill="none" xmlns="http://www.w3.org/2000/svg">
<path class="pathLine" d="M959 7900.5V8039.5" stroke="#F15025"/>
<path class="pathLine" d="M958.236 7890.27C958.575 7889.91 959.425 7889.91 959.764 7890.27L965.88 7896.68C966.22 7897.04 965.795 7897.48 965.116 7897.48H952.884C952.205 7897.48 951.78 7897.04 952.12 7896.68L958.236 7890.27Z" fill="#F15025"/>
<path class="pathLine" d="M958.236 7903.73C958.575 7904.09 959.425 7904.09 959.764 7903.73L965.88 7897.32C966.22 7896.96 965.795 7896.52 965.116 7896.52H952.884C952.205 7896.52 951.78 7896.96 952.12 7897.32L958.236 7903.73Z" fill="#F15025"/>
<path d="M1204.5 6787V6984H1129" stroke="#F15025"/>
<path d="M1204.5 6983V7192H1920.5" stroke="#F15025"/>
<path d="M1204.5 4316L1204.5 5707" stroke="#F15025"/>
<path d="M1128.24 6977.27C1128.58 6976.91 1129.42 6976.91 1129.76 6977.27L1135.88 6983.68C1136.22 6984.04 1135.8 6984.48 1135.12 6984.48H1122.88C1122.2 6984.48 1121.78 6984.04 1122.12 6983.68L1128.24 6977.27Z" fill="#F15025"/>
<path class="pathLine" d="M1128.24 6990.73C1128.58 6991.09 1129.42 6991.09 1129.76 6990.73L1135.88 6984.32C1136.22 6983.96 1135.8 6983.52 1135.12 6983.52H1122.88C1122.2 6983.52 1121.78 6983.96 1122.12 6984.32L1128.24 6990.73Z" fill="#F15025"/>
<path class="pathLine" d="M1204.5 6787.5V5707" stroke="#F15025"/>
<path class="pathLine" d="M785 3465H213V4114.75H1022V4402.5H543.5V4496H1204.5V4571" stroke="#F15025"/>
<path class="pathLine" d="M783.236 3458.27C783.575 3457.91 784.425 3457.91 784.764 3458.27L790.88 3464.68C791.22 3465.04 790.795 3465.48 790.116 3465.48H777.884C777.205 3465.48 776.78 3465.04 777.12 3464.68L783.236 3458.27Z" fill="#F15025"/>
<path d="M783.236 3471.73C783.575 3472.09 784.425 3472.09 784.764 3471.73L790.88 3465.32C791.22 3464.96 790.795 3464.52 790.116 3464.52H777.884C777.205 3464.52 776.78 3464.96 777.12 3465.32L783.236 3471.73Z" fill="#F15025"/>
<path d="M1137.24 3457.27C1137.58 3456.91 1138.42 3456.91 1138.76 3457.27L1144.88 3463.68C1145.22 3464.04 1144.8 3464.48 1144.12 3464.48H1131.88C1131.2 3464.48 1130.78 3464.04 1131.12 3463.68L1137.24 3457.27Z" fill="#F15025"/>
<path d="M1137.24 3470.73C1137.58 3471.09 1138.42 3471.09 1138.76 3470.73L1144.88 3464.32C1145.22 3463.96 1144.8 3463.52 1144.12 3463.52H1131.88C1131.2 3463.52 1130.78 3463.96 1131.12 3464.32L1137.24 3470.73Z" fill="#F15025"/>
<path d="M1693 3297L1693 3464L1139 3464" stroke="#F15025"/>
<path d="M773 1821H184V2736H1693V3297" stroke="#F15025"/>
<path d="M775.236 1813.77C775.575 1813.41 776.425 1813.41 776.764 1813.77L782.88 1820.18C783.22 1820.54 782.795 1820.98 782.116 1820.98H769.884C769.205 1820.98 768.78 1820.54 769.12 1820.18L775.236 1813.77Z" fill="#F15025"/>
<path d="M775.236 1827.23C775.575 1827.59 776.425 1827.59 776.764 1827.23L782.88 1820.82C783.22 1820.46 782.795 1820.02 782.116 1820.02H769.884C769.205 1820.02 768.78 1820.46 769.12 1820.82L775.236 1827.23Z" fill="#F15025"/>
<path d="M1140.24 1813.77C1140.58 1813.41 1141.42 1813.41 1141.76 1813.77L1147.88 1820.18C1148.22 1820.54 1147.8 1820.98 1147.12 1820.98H1134.88C1134.2 1820.98 1133.78 1820.54 1134.12 1820.18L1140.24 1813.77Z" fill="#F15025"/>
<path d="M1140.24 1827.23C1140.58 1827.59 1141.42 1827.59 1141.76 1827.23L1147.88 1820.82C1148.22 1820.46 1147.8 1820.02 1147.12 1820.02H1134.88C1134.2 1820.02 1133.78 1820.46 1134.12 1820.82L1140.24 1827.23Z" fill="#F15025"/>
<path d="M1326.5 1651V1820.5L1146.5 1820.5" stroke="#F15025"/>
<path d="M165 965V1211.5H1205.5H1326.5V1323.5V1652" stroke="#F15025"/>
<path d="M164.236 951.267C164.575 950.911 165.425 950.911 165.764 951.267L171.88 957.679C172.22 958.036 171.795 958.481 171.116 958.481H158.884C158.205 958.481 157.78 958.036 158.12 957.679L164.236 951.267Z" fill="#F15025"/>
<path d="M164.236 964.733C164.575 965.089 165.425 965.089 165.764 964.733L171.88 958.321C172.22 957.964 171.795 957.519 171.116 957.519H158.884C158.205 957.519 157.78 957.964 158.12 958.321L164.236 964.733Z" fill="#F15025"/>
<line x1="165" y1="13" x2="165" y2="189" stroke="#F15025"/>
<path d="M164.236 0.267176C164.575 -0.0890584 165.425 -0.0890587 165.764 0.267175L171.88 6.67939C172.22 7.03562 171.795 7.48092 171.116 7.48092H158.884C158.205 7.48092 157.78 7.03562 158.12 6.67939L164.236 0.267176Z" fill="#F15025"/>
<path d="M164.236 13.7328C164.575 14.0891 165.425 14.0891 165.764 13.7328L171.88 7.32061C172.22 6.96438 171.795 6.51908 171.116 6.51908H158.884C158.205 6.51908 157.78 6.96438 158.12 7.32061L164.236 13.7328Z" fill="#F15025"/>
<path d="M164.236 453.267C164.575 452.911 165.425 452.911 165.764 453.267L171.88 459.679C172.22 460.036 171.795 460.481 171.116 460.481H158.884C158.205 460.481 157.78 460.036 158.12 459.679L164.236 453.267Z" fill="#F15025"/>
<path d="M164.236 466.733C164.575 467.089 165.425 467.089 165.764 466.733L171.88 460.321C172.22 459.964 171.795 459.519 171.116 459.519H158.884C158.205 459.519 157.78 459.964 158.12 460.321L164.236 466.733Z" fill="#F15025"/>
<path d="M165 188V454" stroke="#F15025"/>
</svg>
</div>
body{
margin: 0;
height: 23000px;
background-color: black;
}
#wrap{
position:relative;
}
svg{
position:relative;
width: 600px;
overflow: visible;
margin-top: 0;
}
console.clear();
gsap.registerPlugin(ScrollTrigger, DrawSVGPlugin, MotionPathPlugin);
gsap.set(".pathBall", {xPercent: -50, yPercent: -50});
var dir;
var action = gsap.timeline({defaults: {duration: 1, ease:'none' },
scrollTrigger: {
trigger: "#path",
scrub:0,
start: "top top",
end: "bottom +=220%", // new
onUpdate: self => {
prog = self.progress.toFixed(2);
console.log(prog);
} // new: info for position
}})
.fromTo(".pathLine", {drawSVG: "100% 100%"}, {drawSVG: "0% 100%"}, 0)
.from(".pathBall", {motionPath: {path: ".pathLine", align: ".pathLine", offsetX:0, offsetY:0, }}, 0)
// To compensate for the 'faster' vertical movement, a logic could be defined that counteracts the position of the SVG. Here is a simple experiment adapted to certain sectors (a fixed width of the SVG!).
.to('#wrap', {y:'+=200',duration:0.25,},0)
.to('#wrap', {y:'-=40',duration:0.05,},0.40)
.to('#wrap', {y:'-=800',duration:0.2,},0.5)
.to('#wrap', {y:'-=50',duration:0.2,},0.60)
.to('#wrap', {y:'-=500',duration:0.2,},0.80)
Also see: Tab Triggers