Dot Hopper - Pagination
How do I make an dot hopper - pagination?
Inspired by Chris Gannon's post! http://codepen.io/chrisgannon/details/xVOjZq. What is a dot hopper - pagination? How do you make a dot hopper - pagination? This script and codes were developed by Elliot Geno on 11 September 2022, Sunday.
Dot Hopper - Pagination - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Dot Hopper - Pagination</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <svg viewBox="0 0 300 200">
</svg> <script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.18.2/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>
Dot Hopper - Pagination - Script Codes CSS Codes
body{ margin:0; overflow:hidden; background:#222;
}
svg{ width:100%; height:100vh;
}
Dot Hopper - Pagination - Script Codes JS Codes
var numItems = 5;
var svg = document.querySelector("svg");
var spacing = 25;
var radius = 8;
var strokeWidth=2;
var index = 0;
var ringList=[];
var initX = (300-spacing*(numItems-1))*.5;
var dot = createElement("circle",{cx:initX+(index*spacing),cy:100,fill:"#fff",r:radius-(strokeWidth*2)});
svg.appendChild(dot);
paginate();
disable(ringList[index]);
TweenMax.set(dot,{fill:ringList[index].color});
gotoIndex(3);
function onSelect(e){ gotoIndex(e.target.index);
}
function gotoIndex(targetIndex){ var distance= Math.abs(targetIndex-index)*spacing*.5; var duration=Math.min((distance/spacing)*.2,.4); TweenMax.to(dot,.15,{scaleX:1.5,scaleY:.5,transformOrigin:"bottom",ease:Sine.easeOut,yoyo:true,repeat:1}); TweenMax.to(dot,duration,{delay:.175,fill:ringList[targetIndex].color,x:targetIndex*spacing,ease:Sine.easeInOut}); TweenMax.to(dot,duration*.5,{delay:.175,y:-distance,ease:Sine.easeOut,yoyo:true,repeat:1,onComplete:squish}); enable(ringList[index]); disable(ringList[targetIndex]); index=targetIndex;
}
function enable(target){ target.setAttribute("pointer-events","all");
}
function disable(target){ target.setAttribute("pointer-events","none");
}
function squish(){ TweenMax.to(dot,.15,{scaleX:1.5,scaleY:.75,transformOrigin:"bottom",ease:Sine.easeOut,yoyo:true,repeat:1});
}
function paginate() { for (var i = 0; i < numItems; i++) { var randomColor = "hsl("+(((i/(numItems))*360))+", 65%, 55%)"; var ring = createElement("circle", { cx: initX+(i * spacing), cy: "50%", fillOpacity: 0, r: radius, stroke: randomColor, cursor:"pointer", strokeWidth: strokeWidth, }); ring.index=i; ringList.push(ring); ring.color = randomColor; ring.addEventListener("click",onSelect); svg.appendChild(ring); }
}
function setAttributes(element, attributes) { var keyword, key; for (keyword in attributes) { key = keyword.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase(); element.setAttributeNS(keyword === "xlink:href" ? "http://www.w3.org/1999/xlink" : null, key, attributes[keyword]); }
}
function createElement(type, attributes) { var element = document.createElementNS("http://www.w3.org/2000/svg", type); setAttributes(element, attributes); return element;
}
Developer | Elliot Geno |
Username | pyrografix |
Uploaded | September 11, 2022 |
Rating | 4.5 |
Size | 2,579 Kb |
Views | 38,456 |
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!
Name | Size |
A Pen by Elliot Geno | 2,114 Kb |
Stained Glass | 2,127 Kb |
Gnat Attack | 4,914 Kb |
Cat Silhouette | 4,447 Kb |
Swarm | 2,384 Kb |
Geometric | 1,977 Kb |
Iris | 2,587 Kb |
Bullseye Game | 5,406 Kb |
Solar Explorer | 3,333 Kb |
Crash Loader | 2,615 Kb |
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!
Name | Username | Size |
Heatmap Color Scales | Stevepepple | 2,331 Kb |
Rainbow Drops | Csbarnes | 2,365 Kb |
Out of the blue | Giaco | 2,537 Kb |
Awesome textarea | Ayoungh | 1,977 Kb |
E-mail Template | SoloMDFK | 4,871 Kb |
Adding and Removing Element | Accimeesterlin | 2,119 Kb |
A Pen by Alex Bergin | Abergin | 3,347 Kb |
Halo 5 REQ Guide Bookmarklet | Cwacht | 3,993 Kb |
Heartbeat | Apetrov | 2,079 Kb |
The Fly | GianlucaGuarini | 3,405 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!