Add Rolling Snowball Effect in Divi

|

Add a bit of fun to your Divi theme this holiday with a rolling snowball effect. Here's how to add rolling snowballs to the bottom of any Divi section, row or module. Like this:

"The secret to making the perfect snowball is finding the right type of snow; it should be slightly wet and packable, not too powdery or icy. Scoop up a handful and compress it firmly and evenly with your hands into a smooth, round shape, applying enough pressure to bind the snow together without crushing it into an ice ball. The ideal snowball feels solid but has a bit of give, resisting quick breakage upon impact, embodying both strength and a nice, throwable texture."

To achieve this, first add the following PHP code to your site. It's reasonably long (in part due to the embedded base64 version of the snowball icon), but don't worry – you shouldn't have to modify it in any way:

if ( ! function_exists( 'divibooster_add_rolling_snowballs_to_section' ) ) {
	function divibooster_add_rolling_snowballs_to_section( $output, $render_slug, $module ) {
		if ( is_string( $output ) && isset( $module->props['module_class'] ) && in_array( 'rolling-snowballs', explode( ' ', $module->props['module_class'] ) ) ) {
			$snowball_container = '<div class="rolling-snowballs-container"></div>';
			$output = preg_replace( '/^(<div [^>]*>)/', '$1' . $snowball_container, $output, 1 );
		}
		return $output;
	}
	add_filter( 'et_module_shortcode_output', 'divibooster_add_rolling_snowballs_to_section', 10, 3 );
}

if (!function_exists('divibooster_rolling_snowballs_css')) {
function divibooster_rolling_snowballs_css() {
	?>
<style>
.rolling-snowballs-container {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	overflow: hidden;
	pointer-events: none;
}

@keyframes snowball-roll {
	0% { transform: translateX(-100px) rotate(0); }
	100% { transform: translateX(31410%) rotate(36000deg); } /* 100 rotations */
}

.snowball {
	position: absolute;
	bottom: 0;
	left: 0;
	width: var(--snowball-size);
	height: var(--snowball-size);
	background-size: contain;
	background-repeat: no-repeat;
	opacity: 1;
	animation: snowball-roll var(--snowball-speed) linear forwards infinite;
	background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZlcnNpb249IjEuMSIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub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UzLTE5LjM2OS0yNS43NC0yOC4xNTQtNDYuNjA0LTI0LjA5NGE3LjAwMiA3LjAwMiAwIDAgMS0yLjY3Mi0xMy43NDRjMjcuMzctNS4zMTcgNTAuNTU0IDYuNjcgNjIuMDM0IDMyLjA3MmE3LjAwMSA3LjAwMSAwIDAgMS02LjM3NSA5Ljg4NXpNMTE1LjA5NCAyMjkuNjM1YTcuMDAyIDcuMDAyIDAgMCAxLTYuNTg0LTQuNjIzYy05LjQ3My0yNi4yMTctMS4yLTUwLjk3OCAyMi4xMy02Ni4yMzVhNyA3IDAgMSAxIDcuNjYyIDExLjcxNmMtMTcuNzg4IDExLjYzMy0yMy44NDggMjkuNzctMTYuNjI1IDQ5Ljc2YTcgNyAwIDAgMS00LjIwNSA4Ljk2MiA2Ljk1NiA2Ljk1NiAwIDAgMS0yLjM3OC40MnoiIGZpbGw9IiNkN2QxZDEiIG9wYWNpdHk9IjEiIGRhdGEtb3JpZ2luYWw9IiMwMDAwMDAiIGNsYXNzPSIiPjwvcGF0aD48L2c+PC9zdmc+);
}
	</style>
	<?php
}
add_action( 'wp_head', 'divibooster_rolling_snowballs_css' );
}
if (!function_exists('divibooster_rolling_snowballs_js')) {
function divibooster_rolling_snowballs_js() {
	?>
	<script>
document.addEventListener('DOMContentLoaded', function() {
	var container = document.querySelector('.rolling-snowballs-container');

	function createSnowball() {
		var snowball = document.createElement('div');
		snowball.classList.add('snowball');
		
		// Randomize snowball size
		var minSize = 10;
		var maxSize = 80;
		var power = 2; 
		var sizeRandom = Math.pow(Math.random(), power);
		var size = sizeRandom * (maxSize - minSize) + minSize;
		snowball.style.setProperty('--snowball-size', size + 'px');
		
		// Randomize roll duration		
		var minSpeed = 3;
		var maxSpeed = 10;
		var power = 2;
		var speedRandom = Math.pow(Math.random(), power);
		var speed = (1 - speedRandom) * (maxSpeed - minSpeed) + minSpeed;
		speed = 20 * speed; // Apply a scale factor of 20
		snowball.style.setProperty('--snowball-speed', speed + 's');
		
		container.appendChild(snowball);
		setTimeout(() => snowball.remove(), 120000);
	}

	if (container) {
		setInterval(createSnowball, 2000);
	}
});
	</script>
	<?php
}
add_action( 'wp_footer', 'divibooster_rolling_snowballs_js', 100 );
}

Now, on any section, row or module that you want to add falling snow to, just give it a CSS Class of "rolling-snowballs", like so:

0 Comments

Submit a Comment

Comments are manually moderated and approved at the time they are answered. A preview is shown while pending but may disappear if your are cookies cleared - don't worry though, the comment is still in the queue.

Your email address will not be published. Required fields are marked *.

We may earn a commission when you visit links on our website.