Fixed the text scramble errors, few changes, added animation, testimonial responsive fix.

This commit is contained in:
NoobDeveloper412 2024-09-16 21:13:20 +05:00
parent 0a751eb401
commit af004075f2
6 changed files with 121 additions and 97 deletions

View file

@ -1,6 +1,9 @@
function applyScrambleEffect() { function applyScrambleEffect() {
const glitchTextOnceElements = document.querySelectorAll('.glitch-text'); const glitchTextOnceElements = document.querySelectorAll('.glitch-text');
const glitchTextRepeatElements = document.querySelectorAll('.glitch-text-interval'); const glitchTextRepeatElements = document.querySelectorAll('.glitch-text-interval');
const glitchTextHoverElements = document.querySelectorAll('.glitch-text-hover');
const charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
function animateScramble(element, text, duration = 1000) { function animateScramble(element, text, duration = 1000) {
const chars = []; const chars = [];
@ -25,7 +28,7 @@ function applyScrambleEffect() {
const kk = k * text.length; const kk = k * text.length;
for (let i = 0; i < text.length; i++) { for (let i = 0; i < text.length; i++) {
if (kk < i) { if (kk < i) {
chars[i].innerHTML = String.fromCharCode(~~(65 + rand() * 26)); chars[i].innerHTML = charset[Math.floor(rand() * charset.length)];
} else { } else {
chars[i].innerHTML = text[i] === ' ' ? '&nbsp;' : text[i]; chars[i].innerHTML = text[i] === ' ' ? '&nbsp;' : text[i];
} }
@ -53,6 +56,7 @@ function applyScrambleEffect() {
animate(); animate();
} }
// Use IntersectionObserver for once-only animation
const observer = new IntersectionObserver((entries, observer) => { const observer = new IntersectionObserver((entries, observer) => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.isIntersecting) { if (entry.isIntersecting) {
@ -80,20 +84,22 @@ function applyScrambleEffect() {
animateScramble(element, text); animateScramble(element, text);
} }
}, 5000); }, 5000);
});
// Hover functionality for `.glitch-text-hover` elements
glitchTextHoverElements.forEach((element) => {
const text = element.innerText;
element.addEventListener('mouseenter', () => { element.addEventListener('mouseenter', () => {
// Only start the animation if it isn't already in progress
if (!element.isAnimating) { if (!element.isAnimating) {
clearInterval(intervalId);
animateScramble(element, text, 800);
element.isAnimating = true; element.isAnimating = true;
animateScramble(element, text, 800);
setTimeout(() => {
element.isAnimating = false;
}, 1000);
} }
}); });
// No need for 'mouseleave' as the animation will complete even if the mouse leaves
}); });
} }
document.addEventListener('DOMContentLoaded', applyScrambleEffect);
document.addEventListener('DOMContentLoaded', applyScrambleEffect);

View file

@ -111,7 +111,7 @@ const sortedSections = sectionsConfig
{section.name === "contributors" && ( {section.name === "contributors" && (
<div class="middle-pane-medium"> <div class="middle-pane-medium">
<h1 class="my-6 glitch-text">Contributors</h1> <h1 class="my-6 glitch-text">Contributors</h1>
<div class="flex gap-3 flex-wrap mb-4 items-center"> <div class="flex gap-3 flex-wrap mb-4 items-center justify-center md:justify-start">
{contributors.items.map((contrib) => ( {contributors.items.map((contrib) => (
<div> <div>
<a <a

View file

@ -21,8 +21,10 @@ let currentTestimonial = 0;
--- ---
<div class="w-full mx-auto px-8 border-2 border-[#202020]"> <div class="w-full mx-auto px-8 border-2 border-[#202020]">
<div class="relative testimonial-fade active" id="testimonial-container"> <div class="relative" id="testimonial-container">
<div class="flex items-center justify-center overflow-hidden"> <div
class="flex flex-col md:flex-row my-4 md:my-0 items-center justify-center testimonial-fade active overflow-hidden"
>
<div> <div>
<img <img
src={testimonials[currentTestimonial].imageUrl} src={testimonials[currentTestimonial].imageUrl}

View file

@ -28,7 +28,7 @@ function personLink(person) {
--- ---
<div <div
class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6 gap-4 place-items-center md:place-items-start"
> >
{ {
filteredPeople.map((person) => ( filteredPeople.map((person) => (

View file

@ -58,7 +58,7 @@ for (const e of upcomingEvents) {
class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 w3pn-hp-grid gap-2 mt-2" class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 w3pn-hp-grid gap-2 mt-2"
> >
<div class="bg-events" data-url="/events"> <div class="bg-events" data-url="/events">
<div class="title">Events</div> <div class="title glitch-text">Events</div>
<div class="numbers"> <div class="numbers">
<div> <div>
<div class="big">{eventsUpcoming}</div> <div class="big">{eventsUpcoming}</div>
@ -80,6 +80,7 @@ for (const e of upcomingEvents) {
<div class="text-white mt-1 ml-1.5"> <div class="text-white mt-1 ml-1.5">
<a <a
href="https://github.com/web3privacy/web3privacy/blob/main/README.md#contents" href="https://github.com/web3privacy/web3privacy/blob/main/README.md#contents"
class="glitch-text"
>Web3 Privacy Database</a >Web3 Privacy Database</a
> >
</div> </div>
@ -104,7 +105,7 @@ for (const e of upcomingEvents) {
</div> </div>
</div> </div>
<div class="bg-talks" data-url="/research"> <div class="bg-talks" data-url="/research">
<div class="title">Research</div> <div class="title glitch-text">Research</div>
<div class="numbers"> <div class="numbers">
<div> <div>
<div class="big">{core.research.length} research projects →</div> <div class="big">{core.research.length} research projects →</div>
@ -115,12 +116,9 @@ for (const e of upcomingEvents) {
</div> </div>
<div class="middle-pane-medium mt-10"> <div class="middle-pane-medium mt-10">
<!--div class="mt-10">
<h1>Our Projects</h1>
</div-->
<div class="mt-16"> <div class="mt-16">
<h1>Featured Events</h1> <h1 class="glitch-text">Featured Events</h1>
</div> </div>
<div class="text-left"> <div class="text-left">
@ -149,7 +147,7 @@ for (const e of upcomingEvents) {
</div> </div>
<div class="mt-16"> <div class="mt-16">
<h1>Latest Articles</h1> <h1 class="glitch-text">Latest Articles</h1>
</div> </div>
<div class="w3pn-articles grid md:grid-cols-2 gap-6"> <div class="w3pn-articles grid md:grid-cols-2 gap-6">
@ -180,7 +178,7 @@ for (const e of upcomingEvents) {
</div> </div>
<div class="mt-16"> <div class="mt-16">
<h1>Latest Talks</h1> <h1 class="glitch-text">Latest Talks</h1>
</div> </div>
<div class="grid md:grid-cols-2 gap-6"> <div class="grid md:grid-cols-2 gap-6">

View file

@ -33,6 +33,25 @@
U+2193, U+2212, U+2215, U+FEFF, U+FFFD; U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
} }
.glitch-text {
font-family: Major Mono Display, ui-monospace, SFMono-Regular, Menlo, Monaco,
Consolas, "Liberation Mono", "Courier New", monospace;
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 500ms;
text-transform: lowercase!important;
flex-wrap: nowrap;
}
.testimonial-fade {
opacity: 0;
transition: opacity 0.2s ease-in-out;
}
.testimonial-fade.active {
opacity: 1;
}
@tailwind components; @tailwind components;
@layer components { @layer components {
@ -86,7 +105,6 @@
a.button button { a.button button {
fill: #fff; fill: #fff;
stroke: #fff; stroke: #fff;
} }
a.button button::after { a.button button::after {