Pen Settings

HTML

CSS

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

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

              
                <div class="c-fluid-reveal">

	<div class="c-fluid-reveal__inner">

		<div class="c-fluid-reveal__item">
			<svg class="c-fluid-reveal__item-media" viewBox="0 0 800 1000">
				<image opacity="1" mask="url('#mask-1')" preserveAspectRatio="xMidYMid slice" href="https://images.unsplash.com/photo-1615737005632-21755eed35e1?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8OXx8fGVufDB8fHx8&auto=format&fit=crop&w=800&q=60" height="100%" width="100%" />

				<mask id="mask-1">
					<path id="wobble-1" class="c-fluid-reveal__wobble" d="M53.48-414.83C-36.82-373-33.76-278.17-19.91-194c12.17,74,66.56,136.46,2.05,205.61s-109.6,66-153.69,147.16,31,143.15-55,230.15-274,14.62-267,206S-750.66,726.14-680.2,819.76c75,99.68,487.9,207.62,632,282.55,342.19,177.9,764,148.24,902.86-42.68C994.14,867.89,1031.26,327.21,819.11-35.12,647.45-328.3,300.19-406.44,276.48-428.27,223.48-477.07,92.55-432.94,53.48-414.83Z" fill="white" />
				</mask>
			</svg>
			<div class="c-fluid-reveal__content">

				Content
			</div>
		</div>

		<div class="c-fluid-reveal__item">
			<svg class="c-fluid-reveal__item-media" viewBox="0 0 800 1000">
				<image opacity="1" mask="url('#mask-2')" preserveAspectRatio="xMidYMid slice" href="https://images.unsplash.com/photo-1615538622919-b9949998690d?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8OHx8fGVufDB8fHx8&auto=format&fit=crop&w=800&q=60" height="100%" width="100%" />

				<mask id="mask-2">
					<path id="wobble-2" d="M53.48-414.83C-36.82-373-33.76-278.17-19.91-194c12.17,74,66.56,136.46,2.05,205.61s-109.6,66-153.69,147.16,31,143.15-55,230.15-274,14.62-267,206S-750.66,726.14-680.2,819.76c75,99.68,487.9,207.62,632,282.55,342.19,177.9,764,148.24,902.86-42.68C994.14,867.89,1031.26,327.21,819.11-35.12,647.45-328.3,300.19-406.44,276.48-428.27,223.48-477.07,92.55-432.94,53.48-414.83Z" fill="white" />
				</mask>
			</svg>
			<div class="c-fluid-reveal__content">

				Second Content
			</div>
		</div>

		<div class="c-fluid-reveal__item">
			<svg class="c-fluid-reveal__item-media" viewBox="0 0 800 1000">
				<image opacity="1" mask="url('#mask-3')" preserveAspectRatio="xMidYMid slice" href="https://images.unsplash.com/photo-1615395885697-59118a3c6018?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxleHBsb3JlLWZlZWR8MTc4fHx8ZW58MHx8fHw%3D&auto=format&fit=crop&w=800&q=60" height="100%" width="100%" />

				<mask id="mask-3">
					<path id="wobble-3" d="M53.48-414.83C-36.82-373-33.76-278.17-19.91-194c12.17,74,66.56,136.46,2.05,205.61s-109.6,66-153.69,147.16,31,143.15-55,230.15-274,14.62-267,206
																											S-750.66,726.14-680.2,819.76c75,99.68,487.9,207.62,632,282.55,342.19,177.9,764,148.24,902.86-42.68C994.14,867.89,1031.26,327.21,819.11-35.12,647.45-328.3,300.19-406.44,276.48-428.27,223.48-477.07,92.55-432.94,53.48-414.83Z" fill="white" />
				</mask>
			</svg>
			<div class="c-fluid-reveal__content">

				Third Content
			</div>
		</div>

	</div>

</div>

<footer>
	based on the mask demo by
	<a href="https://codepen.io/cassie-codes">cassie</a> <br>
	see also: cuberto, codrops gl-transitions
</footer>
              
            
!

CSS

              
                .c-fluid-reveal {
	--fluid-reveal-section-height: 140vh;
	height: calc(var(--fluid-reveal-section-height) * var(--items));
}

.c-fluid-reveal__inner {
	display: block;
	min-height: 100vh;
	width: 100%;
}

.c-fluid-reveal__item {
	align-content: center;
	display: grid;
	grid-auto-flow: column;
	grid-gap: 2rem;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr;
	margin: 0;
	position: absolute;
	top: 0;
	width: 100%;
}

.c-fluid-reveal__item-media {
	display: block;
	max-height: 80vh;
	margin-top: 10vh;
	overflow: hidden;
	top: 0;
	width: 100%;
}

.c-fluid-reveal__content {
	align-content: center;
	background: white;
	display: grid;
	grid-column: 2 / span 1;
	//justify-content: center;
	max-height: 100vh;
	will-change: opacity, transform;
}

// demo styles

@import url("https://fonts.googleapis.com/css2?family=Dela+Gothic+One&display=swap");

body {
	font-family: "Dela Gothic One";
	font-size: 200%;
	height: 900vh;
	margin: 0;
	padding: 0 2rem;
}

footer {
	text-align: center;
}

a {
	color: #f75b7c;
	//text-decoration: none;
}

              
            
!

JS

              
                // get elements, nodelist to array
let fluidRevealEls = gsap.utils.toArray(".c-fluid-reveal__item");

// set variable for wrapper height using css calc
let wrapper = document.querySelector(".c-fluid-reveal");
wrapper.style.setProperty("--items", fluidRevealEls.length);

let animateDuration = 2;
let pinDuration = 5;

let wobble;
let content;
let media;
let tl;

ScrollTrigger.saveStyles([
	".c-fluid-reveal__item .c-fluid-reveal__wobble",
	".c-fluid-reveal__item .c-fluid-reveal__media",
	".c-fluid-reveal__item .c-fluid-reveal__content"
]);

ScrollTrigger.matchMedia({
	// desktop
	"(min-width: 800px)": function () {
		//ScrollTrigger.refresh();
		console.log("dt");
		tl = gsap.timeline({
			ease: "none",
			scrollTrigger: {
				trigger: wrapper,
				start: "top top ",
				pin: true,
				end: "bottom bottom",
				scrub: 0.4,
				markers: true
			}
		});

		let count = 1;

		fluidRevealEls.forEach((el) => {
			wobble = el.querySelector("path");
			media = el.querySelector(".c-fluid-reveal__media");
			content = el.querySelector(".c-fluid-reveal__content");

			if (count > 1) {
				tl.from(
					wobble,
					{
						duration: animateDuration,
						xPercent: 100,
						yPercent: 100
					},
					"-=" + animateDuration
				);
			} else {
				tl.from(wobble, {
					duration: animateDuration,
					xPercent: 100,
					yPercent: 100
				});
			}

			tl
				.from(
					content,
					{
						duration: animateDuration,
						opacity: 0,
						yPercent: 100
					},
					"-=" + animateDuration
				)
				.to(el, {
					duration: pinDuration
				});
			if (count < fluidRevealEls.length) {
				tl.to(
					content,
					{
						duration: animateDuration,
						opacity: 0,
						yPercent: -100
					},
					"-=" + animateDuration
				);
			}
			count++;
		});
	},
	"(max-width: 800px)": function () {
		if (tl) {
			tl.kill();
		}
		console.log("mb");
	}
});

              
            
!
999px

Console