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


Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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


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.


                <div class="pointer">
	<img src="" />
	<p class="screen-log">transform: translate(0,0)</p>



                @import url("");

:root {
	--mouse-x: 0;
	--mouse-y: 0;

body {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: #6fdcbf;
	font-family: "Signika", sans-serif;
	overflow: hidden;

.pointer {
	position: relative;
	text-align: center;

.pointer img {
	width: 100px;
	display: block;
	margin: 0 auto;

.screen-log {
	position: absolute;
	bottom: -3rem;
	width: 300%;
	left: -100%;
	padding-top: 1rem;
	text-align: center;


                (function () {
	const safeToAnimate = window.matchMedia('(prefers-reduced-motion: no-preference)').matches;
 if (!safeToAnimate) return;
		// Get the elements that we need
	const pointer = document.querySelector('.pointer')
	const screenLog = document.querySelector('.screen-log');
	let xPosition;
	let yPosition;

	let storedXPosition;
	let storedYPosition;

	// Set up our coordinate mapping with GSAP utils!
	let mapWidth;
	let mapHeight;
	function setMaps() {
		mapWidth = gsap.utils.mapRange(0, innerWidth, -50, 50);
		mapHeight = gsap.utils.mapRange(0, innerHeight, -50, 50);
	window.addEventListener('resize', setMaps);

	// Use .quickSetter for best performance since we're updating values a lot dynamically
	//apply it to the pointer x/y properties and append a "%" unit
	const xSet = gsap.quickSetter(pointer, 'x', '%');
	const ySet = gsap.quickSetter(pointer, 'y', '%');
	function movePointer() {
		// only recalculating if the value changes
		if (storedXPosition === xPosition && storedYPosition === yPosition) return;
		if(xPosition && yPosition){ 
			screenLog.innerText = `transform: translate(${Math.round(xPosition)}%, ${Math.round(yPosition)}%)`;


		// update the stored positions with the current positions
		storedXPosition = xPosition;
		storedYPosition = yPosition;
	// gsap's RAF, falls back to set timeout

	// updating the mouse coordinates
	function updateMouseCoords(event) {
		xPosition = mapWidth(event.clientX);
		yPosition = mapWidth(event.clientY);
	window.addEventListener("mousemove", updateMouseCoords);