Delayed Follow

Developer
Size
2,306 Kb
Views
32,384

How do I make an delayed follow?

TweenMax testing overlapping tweens, click to wreak havoc.. What is a delayed follow? How do you make a delayed follow? This script and codes were developed by Chad Scira on 27 August 2022, Saturday.

Delayed Follow Previews

Delayed Follow - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Delayed Follow</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.5/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Delayed Follow - Script Codes CSS Codes

body {	margin: 0;	background-color: #17293a;	overflow: hidden;
}
.particle {	width: 5px;	height: 5px;	margin-left: -2.5px;	margin-top: -2.5px;	background: #fff;	position: absolute;	backface-visibility: hidden;	-moz-backface-visibility: hidden;	-webkit-backface-visibility: hidden;
}

Delayed Follow - Script Codes JS Codes

function Scene () {	this.render = this.render.bind(this);	this.onClick = this.onClick.bind(this);	this.onMouseMove = this.onMouseMove.bind(this);	this.elements = [];	this.clickAnimating = false;	this.timeline = new TimelineMax({onUpdate: this.render});	this.totalElements = 300;	window.addEventListener('click', this.onClick);	window.addEventListener('mousemove', this.onMouseMove);	this.createElements();	this.render();
}
Scene.prototype = {	createElements: function () {	for (var i = 0; i < this.totalElements; i++) {	var element = document.createElement('div');	element.className = 'particle';	element.backing = {x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight};	document.body.appendChild(element);	this.elements.push(element);	}	},	onMouseMove: function (event) {	if (this.clickAnimating) {	return;	}	this.elements.forEach(function (element) {	this.timeline.to(element.backing, .25 + Math.random()*3, {x: event.pageX + ((Math.random() * 20) - 10), y: event.pageY + ((Math.random() * 20) - 10), ease: Cubic.easeOut}, this.timeline.time());	}, this);	},	onClick: function (event) {	if (this.clickAnimating) {	return;	}	this.clickAnimating = true;	setTimeout(function () {	this.clickAnimating = false;	}.bind(this), 1250);	this.elements.forEach(function (element) {	this.timeline.to(element.backing, .25 + Math.random(), {x: Math.random() * window.innerWidth, y: Math.random() * window.innerHeight, ease: Bounce.easeOut}, this.timeline.time());	}, this);	},	render: function () {	this.elements.forEach(function (element) {	element.style.transform =	element.style.mozTransform =	element.style.webkitTransform = 'translate3d(' + element.backing.x.toFixed(3) + 'px,' + element.backing.y.toFixed(3) + 'px,0)';	}, this);	}
};
new Scene();
Delayed Follow - Script Codes
Delayed Follow - Script Codes
Home Page Home
Developer Chad Scira
Username icodeforlove
Uploaded August 27, 2022
Rating 3
Size 2,306 Kb
Views 32,384
Do you need developer help for Delayed Follow?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Chad Scira (icodeforlove) Script Codes
Create amazing art & images with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!