123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              - var gridSize = 5;

.achiev-banner
	.achiev-name
		="🏅"
		span="Achievement Name"
	.achiev-req="Requirement to Unlock"

- for (var i = 0;i < Math.pow(gridSize, 2); ++i) {
	.eye-track-cell
- }

.length-counter
	="Length "
	br
	span.count="0"
	="px"

.longcat
	.right-ear
	.left-ear
	.right-arm
		.right-paw
	.torso
		.bottom
			.tail
				.tail-outer
			.right-leg
				.right-lower-leg
					.right-foot
			.left-leg
				.left-lower-leg
					.left-foot
	.head
		.right-eye
		.left-eye
		.nose-mouth
		.right-cheek
		.left-cheek
		- for (var i = 0;i < 10; ++i) {
			.whisker
		- }
	.left-arm
		.left-paw
.barrier
            
          
!
            
              @import 'compass';
$dur: 1s;
$hair: rgba(232,232,232,1);
$hairT: rgba(232,232,232,0);
$hairDark: rgba(209,209,209,1);
$hairDarkT: rgba(209,209,209,0);
$ear: rgba(240,192,192,1);
$earT: rgba(240,192,192,0);
$mouth: rgba(224,112,112,1);
$spacer: rgba(162,162,162,1);
$spacerT: rgba(162,162,162,0);
$pawPrint: rgba(139,139,139,1);
$pawPrintT: rgba(139,139,139,0);
$belly: rgba(197,197,197,1);
$whisker: rgba(255,255,255,1);
$whiskerRad: 0.2em;
$t: transparent;
$gridSize: 5; // must match gridSize in Pug
$gridSizeHalved: $gridSize / 2;
$areaW: 100% / $gridSize;

body {
	background-color: rgb(150,125,70);
	color: rgb(23,23,23);
	font: 20px Impact, sans-serif;
	line-height: 1.5;
	margin: 0;
	overflow-x: hidden;
}
div {
	box-sizing: border-box;
	position: absolute;
}

.achiev-banner,
.eye-track-cell,
.length-counter {
	position: fixed;
}
.achiev-banner {
	background-color: rgba(255,255,255,0.9);
	border-radius: 0.75em;
	font-family: system-ui, sans-serif;
	padding: 0.75em 1.5em;
	text-align: center;
	top: 0.75em;
	left: 50%;
	width: calc(100% - 1.5em);
	max-width: 20em;
	transform: translate(-50%,-115%);
	z-index: 3;
	> div {
		position: static;
	}
	.achiev-name {
		font: {
			 size: 1.5em;
			 weight: bold;
		};
	}
}
.achiev-earned {
	animation: achievement 4s linear;
}

/* Longcat cursor tracking with eyes */
.eye-track-cell {
	width: $areaW;
	height: $areaW;
	z-index: 1;
	@for $y from 1 through $gridSize {
		@for $x from 1 through $gridSize {
			$int: ($y - 1)*$gridSize + $x + 1;
			&:nth-of-type(#{$int}) {
				$top: $areaW * ($y - 1);
				$left: $areaW * ($x - 1);
				// strip units if 0
				@if $top == 0 {
					$top: 0;
				}
				@if $left == 0 {
					$left: 0;
				}
				top: $top;
				left: $left;
				&:hover ~ .longcat {
					.right-eye, .left-eye {
						// 1. make center square 0 if $gridSize is odd or skip 0 if even
						// 2. get adjusted $x values by subtracting $gridSize cut in half from $x
						// if even $gridSize
						@if $gridSize % 2 == 0 {
							@if $x <= $gridSizeHalved {
								$x: $x - ($gridSizeHalved + 1);
							} @else {
								$x: $x - $gridSizeHalved;
							}
						}
						// if odd $gridSize
						@else {
							$x: $x - ceil($gridSizeHalved);
						}
						
						$deg: atan(-$x / ($y - 1)) * 180/pi();
						// for odd $gridSize, make the eyes use 0deg for cell 0,0 instead of NaN
						@if $int == ceil($gridSizeHalved) + 1 and $gridSize % 2 != 0 {
								$deg: 0;
						}
						transform: rotate(0deg + $deg);
					}
				}
			}
		}
	}
}
.length-counter {
	top: 0.75em;
	left: 0.75em;
	z-index: 2;
}
.count {
	color: #fff;
	font-size: 2em;
	line-height: 1;
	-webkit-text-stroke: 2px #111;
}

/* Longcat herself */
.longcat, .barrier {
	position: relative;
}
.longcat {
	font-size: 0.5em;
	margin: auto;
	width: 34.5em;
	height: 101vh;
	transition: height 0.2s ease-out;
}
.right-ear,
.left-ear,
.right-arm,
.right-paw,
.head,
.right-cheek,
.left-cheek,
.left-arm,
.left-paw,
.tail,
.tail-outer,
.tail-outer::after {
	background-color: $hair;
}
.right-arm,
.right-paw,
.right-eye,
.left-eye,
.head,
.right-leg,
.left-leg {
	border-radius: 50%;
}
/* Top */
.right-ear {
	background-image: radial-gradient(
		75% 225% at 25% 100%,
		$ear,
		$ear 50%,
		$earT 51%
	);
	border-radius: 4em 4em 0 0 / 16em 16em 0 0;
	width: 2em;
	height: 4em;
	top: 1em;
	left: 11.5em;
	transform: rotate(-40deg);
}
.left-ear {
	background-image: radial-gradient(
		75% 188% at 50% 100%,
		$ear,
		$ear 50%,
		$t 51%
	);
	border-radius: 8em 8em 0 0 / 16em 16em 0 0;
	width: 3em;
	height: 4em;
	left: 20.5em;
	transform: rotate(30deg);
}
.right-arm {
	background-image: linear-gradient(
		$hairDarkT,
		$hairDarkT 30%,
		$hairDark 31%
	);
	width: 13em;
	height: 4.5em;
	top: 7em;
	left: 3.5em;
	transform: rotate(15deg);
}
.right-paw {
	background-image:
		radial-gradient(
			2.4em 2.6em at 1.8em 1.3em,
			$hairDark,
			$hairDark 50%,
			$hairDarkT 51%
		),
		radial-gradient(
			2.4em 2.3em at 2.1em 1em,
			$spacer,
			$spacer 50%,
			$hairDarkT 51%
		),
		radial-gradient(
			2.4em 2.6em at 3.8em 1.3em,
			$hairDark,
			$hairDark 50%,
			$hairDarkT 51%
		),
		radial-gradient(
			2.4em 2.4em at 4.1em 1.2em,
			$spacer,
			$spacer 50%,
			$spacerT 51%
		),
		radial-gradient(
			2.4em 2.6em at 4.9em 1.3em,
			$hairDark,
			$hairDark 50%,
			$hairDarkT 51%
		),
		radial-gradient(
			2.4em 2.4em at 5.2em 1.2em,
			$spacer,
			$spacer 50%,
			$spacerT 51%
		),
		linear-gradient(
			$hairDark,
			$hairDark 72%,
			$hairDarkT 73%
		);
	border-radius: 3em;
	width: 7.2em;
	height: 3.6em;
	top: 0.8em;
	left: 0;
	transform: rotate(165deg) {
		origin: 1.8em 1.8em;	
	};
}
.head {
	background-image:
		radial-gradient(
			2em 2em at 38% 53%,
				$hair,
				$hair 50%,
				$hairT 51%
		),
		radial-gradient(
			95% 80% at 45% 63%,
				$hairDark,
				$hairDark 50%,
				$hairDarkT 51%
		);
	width: 12em;
	height: 9em;
	top: 2.8em;
	left: 12em;
	transform: rotate(-5deg);
}
.right-eye, .left-eye {
	background-color: rgb(0,0,0);
	box-shadow: 0 0.2em 0 0.2em rgb(160,160,80) inset;
	width: 2em;
	height: 2em;
	top: 2.5em;
	transition: transform 0.2s linear;
	transform: rotate(-135deg);
}
.right-eye {
	left: 1.5em;
}
.left-eye {
	left: 5.5em;
}
.nose-mouth {
	background-color: $mouth;
	background-image: 
		radial-gradient(
			0.5em 0.5em at 0.8em 0.7em,
			rgb(0,0,0),
			rgb(0,0,0) 50%,
			$t 60%
		),
		radial-gradient(
			0.5em 0.5em at 1.6em 0.7em,
			rgb(0,0,0),
			rgb(0,0,0) 50%,
			$t 60%
		),
		radial-gradient(
			1.6em 0.1em at 1.2em 2.2em,
			rgb(0,0,0),
			rgb(0,0,0) 50%,
			$t 60%
		);
	border-radius: 50% 50% 33% 33%;
	width: 2.5em;
	height: 2.5em;
	top: 4.5em;
	left: 3.2em;
}
.right-cheek, .left-cheek {
	background: {
		color: $hairDark;
		image:
			radial-gradient(
					$whiskerRad $whiskerRad at 0.6em 0.6em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 1.2em 0.3em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 1.8em 0.6em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 0.6em 1.2em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 1.2em 0.9em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 1.8em 1.2em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			),
			radial-gradient(
					$whiskerRad $whiskerRad at 1.2em 1.5em,
					$spacer,
					$spacer 50%,
					$spacerT 60%
			);
	};
	border-radius: 50%;
	width: 2.5em;
	height: 2em;
	top: 5em;
}
.right-cheek {
	left: 2em;
	transform: rotate(-8deg);
}
.left-cheek {
	left: 4.4em;
	transform: rotate(8deg);
}
.left-arm {
	background-image: linear-gradient($hairDarkT,$hairDarkT 30%,$hairDark 31%);
	border-radius: 50%;
	width: 10.5em;
	height: 4.5em;
	top: 6.5em;
	left: 18.9em;
	transform: rotate(40deg);
}
.left-paw {
	background-image:
		radial-gradient(
				0.6em 0.9em at 20% 60%,
				$pawPrint,
				$pawPrint 50%,
				$pawPrintT 55%
		),
		radial-gradient(
				0.6em 0.9em at 38% 40%,
				$pawPrint,
				$pawPrint 50%,
				$pawPrintT 55%
		),
		radial-gradient(
				0.6em 0.9em at 60% 40%,
				$pawPrint,
				$pawPrint 50%,
				$pawPrintT 55%
		),
		radial-gradient(
				0.6em 0.9em at 80% 60%,
				$pawPrint,
				$pawPrint 50%,
				$pawPrintT 55%
		),
		radial-gradient(
				1.5em 1.5em at 50% 75%,
				$pawPrint,
				$pawPrint 50%,
				$pawPrintT 55%
		),
		radial-gradient(
			87% 87% at 54% 55%,
				$hairDark,
				$hairDark 50%,
				$pawPrintT 51%
		);
	border-radius: 3em;
	width: 4.5em;
	height: 4.5em;
	top: 0;
	left: -1em;
	transform: rotate(-50deg);
}
.whisker {
	border-top: 0.1em solid rgb(255,255,255);
	width: 6em;
	height: 0;
	&:nth-child(n+6):nth-child(-n+10) {
		transform-origin: 100% 0;
	}
	&:nth-child(n+11):nth-child(-n+15) {
		transform-origin: 0 0;
	}
	&:nth-child(6) {
		transform: rotate(5deg);
		top: 5.2em;
		left: -2.8em;
	}
	&:nth-child(7) {
		transform: rotate(-3deg);
		top: 5.6em;
		left: -3.4em;
	}
	&:nth-child(8) {
		transform: rotate(-13deg);
		top: 5.9em;
		left: -2.8em;
	}
	&:nth-child(9) {
		transform: rotate(-20deg);
		top: 6.2em;
		left: -3.4em;
	}
	&:nth-child(10) {
		transform: rotate(-29deg);
		top: 6.5em;
		left: -2.7em;
	}
	&:nth-child(11) {
		transform: rotate(5deg);
		top: 5.2em;
		left: 5.7em;
	}
	&:nth-child(12) {
		transform: rotate(7deg);
		top: 5.6em;
		left: 6.2em;
	}
	&:nth-child(13) {
		transform: rotate(12deg);
		top: 5.8em;
		left: 5.6em;
	}
	&:nth-child(14) {
		transform: rotate(18deg);
		top: 6.2em;
		left: 6.2em;
	}
	&:nth-child(15) {
		transform: rotate(21deg);
		top: 6.5em;
		left: 5.5em;
	}
}
/* Body */
.torso {
	animation: hang $dur linear infinite alternate;
	background-color: $belly;
	border-radius: 2.5em / 16em 16em 2em 2em;
	box-shadow: -0.3em 0 0 2em $hairDark inset;
	top: 8.4em;
	left: 13.5em;
	min-height: 28em;
	height: calc(100% - 32em);
	width: 11.5em;
	position: relative;
	transform: rotate(0deg) {
		origin: 5.7em 0;
	};
	transition: height 0.25s ease-out;
}
.bottom {
	background-color: $belly;
	border-radius: 0 0 8em 8em / 0 0 16em 16em;
	box-shadow: -0.3em -2em 0 2em $hairDark inset;
	top: calc(100% - 2em);
	width: 100%;
	height: 10em;
	&::after {
		content: "";
		display: block;
		width: 100%;
		height: 30em;
	}
}
.tail, .tail-outer {
	background-image: linear-gradient($hairDarkT,$hairDarkT 30%,$hairDark 31%);
	border-radius: 0 2em 2em 0;
	height: 4em;
}
.tail {
	animation: wagTail $dur*2 ease-in infinite alternate;
	width: 10em;
	top: 0;
	left: 50%;
	transform: rotate(30deg) {
		origin: 0 2em;
	};
	z-index: -1;
}
.tail-outer {
	animation: wagOuterTail $dur*2 ease-in infinite alternate;
	transform: rotate(-30deg) {
		origin: 0 2em;
	};
	width: 8em;
	left: 8em;
	&::after {
		background-image: linear-gradient(160deg,$hairDarkT,$hairDarkT 40%,$hairDark 41%);
		border: {
			left: 0.1em solid $hair * 0.7;
			radius: 50%;
		};
		content: "";
		display: block;
		margin: 0 0 0 auto;
		height: 4em;
		width: 4em;
	}
}
.right-leg, 
.left-leg, 
.right-lower-leg, 
.left-lower-leg,
.right-foot, 
.left-foot {
	background-color: $hairDark;
	z-index: -2;
}
.right-leg, .left-leg {
	animation: pivotLeg $dur linear infinite alternate;
	top: 2em;
	height: 13em;
	width: 5.5em;
	transform-origin: 2.7em 2.7em;
}
.left-leg {
	right: 0;
}
.right-lower-leg, 
.left-lower-leg {
	border-radius: 15% 15% 50% 50%;
	top: 73%;
	height: 9em;
	width: 4.4em;
	transform-origin: 2.2em 2.2em;
}
.right-lower-leg {
	left: 0.6em;
	transform: rotate(-5deg);
}
.left-lower-leg {
	left: 0.3em;
	transform: rotate(5deg);
}
.right-foot, .left-foot {
	background-image:
		radial-gradient(
			0.3em 1.5em at 25% 93%,
				$spacer,
				$spacer 50%,
				$t 60%
		),
		radial-gradient(
			0.3em 1.5em at 50% 93%,
				$spacer,
				$spacer 50%,
				$t 60%
		),
		radial-gradient(
			0.3em 1.5em at 75% 93%,
				$spacer,
				$spacer 50%,
				$t 60%
		);
	border-radius: 2em;
	transform-origin: 1em 1em;
	top: 67%;
	left: 0.5em;
	height: 8.4em;
	width: 3.5em;
}
.right-foot {
	transform: rotate(15deg);
}
.left-foot {
	transform: rotate(-15deg);
}

/* To be observed by IntersectionObserver */
.barrier {
	width: 100%;
	height: 3em;
}

/* Animations */
@keyframes hang {
	from { transform: rotate(0.5deg) }
	to { transform: rotate(-0.5deg) }
}
@keyframes pivotLeg {
	from { transform: rotate(1.5deg) }
	to { transform: rotate(-1.5deg) }
}
@keyframes wagTail {
	from, 50% { transform: rotate(30deg) }
	to { transform: rotate(20deg) }
}
@keyframes wagOuterTail {
	from, 50% { transform: rotate(-30deg) }
	to { transform: rotate(-60deg) }
}
@keyframes achievement {
	from { transform: translate(-50%,-115%) }
	10%, 90% { transform: translate(-50%,0) }
	to { transform: translate(-50%,-115%) }
}
            
          
!
            
              (longcat => {
	var cat = document.querySelector(".longcat"),
		catHeight = cat.offsetHeight,
		catGrowAmount = 11,
		achievBanner = document.querySelector(".achiev-banner"),
		achievName = document.querySelector(".achiev-name span"),
		achievReq = document.querySelector(".achiev-req"),
		lengthCt = document.querySelector(".count"),
		numberF = new Intl.NumberFormat("en-US"),
		achievements = [
			{name: "Looooong", pts: 1000},
			{name: "Loooooooooong", pts: 2000},
			{name: "The Mile Stone", pts: 5280},
			{name: "Leviacat", pts: 10000},
			{name: "Catzilla", pts: 15000},
			{name: "Pierce the Clouds", pts: 20000},
			{name: "Catch the White Dots", pts: 25000},
			{name: "Catch Poptart Cats", pts: 35000},
			{name: "Felinity and Beyond!", pts: 99999}
		],
		observerOptions = {
			root: null,
			rootMargin: "0px",
			threshold: 1.0
		},
		observer = new IntersectionObserver((entries, observer) => { 
			entries.forEach(entry => {
				if (entry.isIntersecting) {
					// increase cat length
					catHeight += catGrowAmount;
					lengthCt.innerHTML = catHeight;
					cat.style.height = catHeight + "px";
					
					// check if achievement reached
					for (let a of achievements) {
						if (catHeight >= a.pts && catHeight <= a.pts + catGrowAmount) {
							achievBanner.className = "achiev-banner achiev-earned";
							setTimeout(() => {
								achievBanner.className = "achiev-banner";
							}, 4000);
							achievName.innerHTML = a.name;
							achievReq.innerHTML = "Reached " + numberF.format(a.pts) + "px";
						}
					}

					window.scrollBy({
						top: -entry.boundingClientRect.height,
						left: 0,
						behavior: "smooth"
					});
				}
			});
		}, observerOptions),
		barrier = document.querySelector('.barrier');
	
	observer.observe(barrier);
	
	// initial height
	lengthCt.innerHTML = catHeight;
})();
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console