From bf5bc90733d16bbe3c5e92ede5e6b806c70db618 Mon Sep 17 00:00:00 2001 From: Ashwani Senapati Date: Sat, 17 Jan 2026 08:32:16 +0530 Subject: [PATCH] fix:scroll issues in phone --- src/app/components/Home.jsx | 652 ++++++++++++++++++++++++++++-------- 1 file changed, 506 insertions(+), 146 deletions(-) diff --git a/src/app/components/Home.jsx b/src/app/components/Home.jsx index d8167e8..4d17bd9 100644 --- a/src/app/components/Home.jsx +++ b/src/app/components/Home.jsx @@ -238,10 +238,408 @@ // // ); // } +// import { Canvas } from "@react-three/fiber"; +// import { OrbitControls } from "@react-three/drei"; +// import { Sphere, Line } from "@react-three/drei"; +// import { useRef, useMemo } from "react"; +// import { useFrame } from "@react-three/fiber"; +// import { EffectComposer, Bloom } from "@react-three/postprocessing"; +// import { motion } from "framer-motion"; +// import Navbar from "./Navbar"; + +// const Glow = ({ className = "" }) => ( +//
+// ); + +// // Navbar placeholder + + +// function AnimatedNeuralNode({ position, color, size = 0.08, delay = 0 }) { +// const ref = useRef(); + +// useFrame((state) => { +// if (ref.current) { +// // Subtle pulsing animation with individual delay +// const time = state.clock.elapsedTime + delay; +// ref.current.scale.x = 1 + Math.sin(time * 2) * 0.15; +// ref.current.scale.y = 1 + Math.sin(time * 2) * 0.15; +// ref.current.scale.z = 1 + Math.sin(time * 2) * 0.15; +// } +// }); + +// return ( +// +// +// +// ); +// } +// // Add this component after the imports +// function ElectricCircuitBackground() { +// return ( +// +// {/* Main circuit grid */} +// + +// {/* Floating circuit lines */} +// {Array.from({ length: 20 }).map((_, i) => { +// const x = (Math.random() - 0.5) * 40; +// const y = (Math.random() - 0.5) * 40; +// const length = 3 + Math.random() * 5; + +// return ( +// +// ); +// })} + +// {/* Circuit nodes */} +// {Array.from({ length: 30 }).map((_, i) => ( +// +// +// +// ))} +// +// ); +// } +// function NeuralStructure({ +// position = [0, 0, 0], +// color = "#00faff", +// structureIndex = 0, +// }) { +// // Generate fixed node positions based on structure index +// const nodes = useMemo(() => { +// const nodePositions = []; +// const nodeCount = 12; +// const radius = 1.2; + +// // Create a spherical distribution of nodes +// for (let i = 0; i < nodeCount; i++) { +// const phi = Math.acos(-1 + (2 * i) / nodeCount); +// const theta = Math.sqrt(nodeCount * Math.PI) * phi + structureIndex; + +// nodePositions.push([ +// radius * Math.cos(theta) * Math.sin(phi), +// radius * Math.sin(theta) * Math.sin(phi), +// radius * Math.cos(phi), +// ]); +// } +// return nodePositions; +// }, [structureIndex]); + +// // Generate fixed connections +// const connections = useMemo(() => { +// const conns = []; +// const nodeCount = nodes.length; + +// for (let i = 0; i < nodeCount; i++) { +// // Connect to nearest neighbors +// const distances = nodes.map((node, j) => ({ +// index: j, +// distance: Math.hypot( +// node[0] - nodes[i][0], +// node[1] - nodes[i][1], +// node[2] - nodes[i][2] +// ), +// })); + +// distances.sort((a, b) => a.distance - b.distance); + +// // Connect to 3 nearest neighbors +// for (let j = 1; j <= 3 && j < distances.length; j++) { +// const targetIndex = distances[j].index; +// if (i < targetIndex) { // Avoid duplicate connections +// conns.push([i, targetIndex]); +// } +// } +// } +// return conns; +// }, [nodes]); + +// return ( +// +// {nodes.map((pos, i) => ( +// +// ))} + +// {connections.map(([start, end], i) => ( +// +// ))} +// +// ); +// } + +// export default function Home() { +// const colors = [ +// "#00faff", // Cyan +// "#00d9ff", // Light blue +// "#00bfff", // Sky blue +// "#1e90ff", // Dodger blue +// "#007fff", // Azure +// "#4dffff", // Electric cyan +// ]; + +// // Fixed positions covering entire viewport in 3D space +// const structures = useMemo(() => { +// const positions = [ +// // Top row - Front layer +// [-8, 5, 2], +// [-4, 6, 2], +// [0, 5.5, 2], +// [4, 6, 2], +// [8, 5, 2], + +// // Middle-top row +// [-7, 3, 0], +// [-3.5, 3.5, 0], +// [0, 3, 0], +// [3.5, 3.5, 0], +// [7, 3, 0], + +// // Center row +// [-8, 0, -1], +// [-4, 0, -1], +// [0, 0, -1], +// [4, 0, -1], +// [8, 0, -1], + +// // Middle-bottom row +// [-7, -3, 0], +// [-3.5, -3.5, 0], +// [0, -3, 0], +// [3.5, -3.5, 0], +// [7, -3, 0], + +// // Bottom row - Front layer +// [-8, -5, 2], +// [-4, -6, 2], +// [0, -5.5, 2], +// [4, -6, 2], +// [8, -5, 2], + +// // Back layer scattered +// [-6, 4, -4], +// [6, 4, -4], +// [-6, -4, -4], +// [6, -4, -4], +// [0, 5, -4], +// [0, -5, -4], + + +// ]; + +// return positions.map((position, i) => ({ +// position, +// color: colors[i % colors.length], +// structureIndex: i, +// })); +// }, []); +// function CyberGridBackground() { +// const gridRef = useRef(); + +// useFrame((state) => { +// if (gridRef.current) { +// // Subtle movement +// gridRef.current.position.x = Math.sin(state.clock.elapsedTime * 0.1) * 0.5; +// gridRef.current.position.y = Math.cos(state.clock.elapsedTime * 0.08) * 0.5; +// } +// }); + +// return ( +// +// {/* Main grid plane */} +// +// +// +// + +// {/* Vertical grid lines */} +// +// +// +// + +// {/* Glowing data points */} +// {Array.from({ length: 50 }).map((_, i) => ( +// +// +// +// +// ))} +// +// ); +// } + +// return ( +//
+// + +// {/* Content Section */} +//
+//
+// +// +// +// +// MACHINE LEARNING FOR EVERYONE +// + +// +// (ML4E) +// + +// +// THE OFFICIAL MACHINE LEARNING CLUB OF NIT ROURKELA +// +// +// +//
+ +// {/* 3D Canvas */} +//
+// +// +// +// +// +// + +// {structures.map((props, i) => ( +// +// ))} + +// + +// +// +// +// +//
+//
+//
+// ); +// } import { Canvas } from "@react-three/fiber"; import { OrbitControls } from "@react-three/drei"; import { Sphere, Line } from "@react-three/drei"; -import { useRef, useMemo } from "react"; +import { useRef, useMemo, useEffect, useState } from "react"; import { useFrame } from "@react-three/fiber"; import { EffectComposer, Bloom } from "@react-three/postprocessing"; import { motion } from "framer-motion"; @@ -254,15 +652,11 @@ const Glow = ({ className = "" }) => ( /> ); -// Navbar placeholder - - function AnimatedNeuralNode({ position, color, size = 0.08, delay = 0 }) { const ref = useRef(); useFrame((state) => { if (ref.current) { - // Subtle pulsing animation with individual delay const time = state.clock.elapsedTime + delay; ref.current.scale.x = 1 + Math.sin(time * 2) * 0.15; ref.current.scale.y = 1 + Math.sin(time * 2) * 0.15; @@ -281,66 +675,17 @@ function AnimatedNeuralNode({ position, color, size = 0.08, delay = 0 }) { ); } -// Add this component after the imports -function ElectricCircuitBackground() { - return ( - - {/* Main circuit grid */} - - - {/* Floating circuit lines */} - {Array.from({ length: 20 }).map((_, i) => { - const x = (Math.random() - 0.5) * 40; - const y = (Math.random() - 0.5) * 40; - const length = 3 + Math.random() * 5; - - return ( - - ); - })} - - {/* Circuit nodes */} - {Array.from({ length: 30 }).map((_, i) => ( - - - - ))} - - ); -} + function NeuralStructure({ position = [0, 0, 0], color = "#00faff", structureIndex = 0, }) { - // Generate fixed node positions based on structure index const nodes = useMemo(() => { const nodePositions = []; const nodeCount = 12; const radius = 1.2; - // Create a spherical distribution of nodes for (let i = 0; i < nodeCount; i++) { const phi = Math.acos(-1 + (2 * i) / nodeCount); const theta = Math.sqrt(nodeCount * Math.PI) * phi + structureIndex; @@ -354,13 +699,11 @@ function NeuralStructure({ return nodePositions; }, [structureIndex]); - // Generate fixed connections const connections = useMemo(() => { const conns = []; const nodeCount = nodes.length; for (let i = 0; i < nodeCount; i++) { - // Connect to nearest neighbors const distances = nodes.map((node, j) => ({ index: j, distance: Math.hypot( @@ -372,10 +715,9 @@ function NeuralStructure({ distances.sort((a, b) => a.distance - b.distance); - // Connect to 3 nearest neighbors for (let j = 1; j <= 3 && j < distances.length; j++) { const targetIndex = distances[j].index; - if (i < targetIndex) { // Avoid duplicate connections + if (i < targetIndex) { conns.push([i, targetIndex]); } } @@ -409,77 +751,11 @@ function NeuralStructure({ ); } -export default function Home() { - const colors = [ - "#00faff", // Cyan - "#00d9ff", // Light blue - "#00bfff", // Sky blue - "#1e90ff", // Dodger blue - "#007fff", // Azure - "#4dffff", // Electric cyan - ]; - - // Fixed positions covering entire viewport in 3D space - const structures = useMemo(() => { - const positions = [ - // Top row - Front layer - [-8, 5, 2], - [-4, 6, 2], - [0, 5.5, 2], - [4, 6, 2], - [8, 5, 2], - - // Middle-top row - [-7, 3, 0], - [-3.5, 3.5, 0], - [0, 3, 0], - [3.5, 3.5, 0], - [7, 3, 0], - - // Center row - [-8, 0, -1], - [-4, 0, -1], - [0, 0, -1], - [4, 0, -1], - [8, 0, -1], - - // Middle-bottom row - [-7, -3, 0], - [-3.5, -3.5, 0], - [0, -3, 0], - [3.5, -3.5, 0], - [7, -3, 0], - - // Bottom row - Front layer - [-8, -5, 2], - [-4, -6, 2], - [0, -5.5, 2], - [4, -6, 2], - [8, -5, 2], - - // Back layer scattered - [-6, 4, -4], - [6, 4, -4], - [-6, -4, -4], - [6, -4, -4], - [0, 5, -4], - [0, -5, -4], - - - ]; - - return positions.map((position, i) => ({ - position, - color: colors[i % colors.length], - structureIndex: i, - })); - }, []); - function CyberGridBackground() { +function CyberGridBackground() { const gridRef = useRef(); useFrame((state) => { if (gridRef.current) { - // Subtle movement gridRef.current.position.x = Math.sin(state.clock.elapsedTime * 0.1) * 0.5; gridRef.current.position.y = Math.cos(state.clock.elapsedTime * 0.08) * 0.5; } @@ -487,7 +763,6 @@ export default function Home() { return ( - {/* Main grid plane */} - {/* Vertical grid lines */} - {/* Glowing data points */} {Array.from({ length: 50 }).map((_, i) => ( { + const checkMobile = () => { + setIsMobile(window.innerWidth < 768); + }; + + checkMobile(); + window.addEventListener('resize', checkMobile); + return () => window.removeEventListener('resize', checkMobile); + }, []); + + const structures = useMemo(() => { + const positions = [ + [-8, 5, 2], + [-4, 6, 2], + [0, 5.5, 2], + [4, 6, 2], + [8, 5, 2], + [-7, 3, 0], + [-3.5, 3.5, 0], + [0, 3, 0], + [3.5, 3.5, 0], + [7, 3, 0], + [-8, 0, -1], + [-4, 0, -1], + [0, 0, -1], + [4, 0, -1], + [8, 0, -1], + [-7, -3, 0], + [-3.5, -3.5, 0], + [0, -3, 0], + [3.5, -3.5, 0], + [7, -3, 0], + [-8, -5, 2], + [-4, -6, 2], + [0, -5.5, 2], + [4, -6, 2], + [8, -5, 2], + [-6, 4, -4], + [6, 4, -4], + [-6, -4, -4], + [6, -4, -4], + [0, 5, -4], + [0, -5, -4], + ]; + + return positions.map((position, i) => ({ + position, + color: colors[i % colors.length], + structureIndex: i, + })); + }, [colors]); + return (
{/* Content Section */}
-
+
MACHINE LEARNING FOR EVERYONE @@ -578,7 +915,7 @@ export default function Home() { hidden: { opacity: 0, scale: 0.9 }, visible: { opacity: 1, scale: 1, transition: { duration: 0.8, ease: "easeOut" } } }} - className="text-2xl md:text-5xl font-bold text-cyan-300 drop-shadow-[0_0_15px_#00d9ff] mb-4" + className={`${isMobile ? 'text-xl' : 'text-2xl md:text-5xl'} font-bold text-cyan-300 drop-shadow-[0_0_15px_#00d9ff] mb-4`} style={{ fontFamily: "Orbitron, sans-serif" }} > (ML4E) @@ -589,7 +926,7 @@ export default function Home() { hidden: { opacity: 0, y: 20 }, visible: { opacity: 1, y: 0, transition: { duration: 0.8, ease: "easeOut" } } }} - className="mt-2 text-base md:text-xl text-blue-300 drop-shadow-[0_0_10px_#00d9ff]" + className={`mt-2 ${isMobile ? 'text-sm' : 'text-base md:text-xl'} text-blue-300 drop-shadow-[0_0_10px_#00d9ff]`} style={{ fontFamily: "Roboto, sans-serif" }} > THE OFFICIAL MACHINE LEARNING CLUB OF NIT ROURKELA @@ -598,9 +935,13 @@ export default function Home() {
- {/* 3D Canvas */} + {/* 3D Canvas with touch event handling */}
- + @@ -611,16 +952,19 @@ export default function Home() { ))} - + {/* Disable controls on mobile */} + {!isMobile && ( + + )} + + {/* Overlay for mobile to allow scrolling through the canvas */} + {isMobile && ( +
+ )}
+ + {/* Add scrollable content area */} +
);