Skip to content

bug fix: z-index issue #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions components/website/hero-sec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable @next/next/no-img-element */
/* eslint-disable @next/next/no-html-link-for-pages */
'use client';
import { ArrowRight, ChevronsRight, Component, MoveRight } from 'lucide-react';
import { ArrowRight, ChevronsRight, Component, Divide, MoveRight } from 'lucide-react';
import { Button } from '@/components/website/ui/button';
import React, { useEffect, useMemo, useState } from 'react';
import Link from 'next/link';
Expand Down Expand Up @@ -90,29 +90,27 @@ function HeroSec() {
{
title: 'Bubble Cursor',
link: '/components/bubble-cursor',
component: <BubbleCursor />,
component: <BubbleCursor zIndex={1} />,
},
{
title: 'Character Cursor',
link: '/components/character-cursor',
component: <CharacterCursor />,
component: <CharacterCursor zIndex={1} />,
},
{
title: 'Snowflake Cursor',
link: '/components/character-cursor',
component: <SnowflakeCursor />,
component: <SnowflakeCursor zIndex={1} />,
},

{
title: 'Rainbow Cursor',
link: '/components/rainbow-cursor',

component: <RainbowCursor />,
component: <RainbowCursor zIndex={1} />,
},
{
title: 'Follow Cursor',
link: '/components/follow-cursor',

component: <FollowCursor />,
},
{
Expand All @@ -123,7 +121,7 @@ function HeroSec() {
{
title: 'Springy Cursor',
link: '/components/springy-cursor',
component: <SpringyCursor />,
component: <SpringyCursor zIndex={1} />,
},
];
return (
Expand Down
4 changes: 3 additions & 1 deletion registry/components/cursor/common/bubble-cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useEffect, useRef } from 'react';

interface BubbleCursorProps {
wrapperElement?: HTMLElement;
zIndex?: number;
}

class Particle {
Expand Down Expand Up @@ -49,7 +50,7 @@ class Particle {
context.closePath();
}
}
const BubbleCursor: React.FC<BubbleCursorProps> = ({ wrapperElement }) => {
const BubbleCursor: React.FC<BubbleCursorProps> = ({ wrapperElement, zIndex }) => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const particlesRef = useRef<Particle[]>([]);
const cursorRef = useRef({ x: 0, y: 0 });
Expand Down Expand Up @@ -81,6 +82,7 @@ const BubbleCursor: React.FC<BubbleCursorProps> = ({ wrapperElement }) => {
canvas.style.top = '0px';
canvas.style.left = '0px';
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = zIndex ? zIndex.toString() : '';

if (wrapperElement) {
canvas.style.position = 'absolute';
Expand Down
3 changes: 3 additions & 0 deletions registry/components/cursor/common/character-cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface CharacterCursorProps {
characters?: string[];
colors?: string[];
cursorOffset?: { x: number; y: number };
zIndex?: number;
font?: string;
characterLifeSpanFunction?: () => number;
initialCharacterVelocityFunction?: () => { x: number; y: number };
Expand Down Expand Up @@ -50,6 +51,7 @@ const CharacterCursor: React.FC<CharacterCursorProps> = ({
Math.max(((lifeSpan - age) / lifeSpan) * 2, 0),
characterNewRotationDegreesFunction = (age, lifeSpan) => (lifeSpan - age) / 5,
wrapperElement,
zIndex,
}) => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const particlesRef = useRef<Particle[]>([]);
Expand Down Expand Up @@ -146,6 +148,7 @@ const CharacterCursor: React.FC<CharacterCursorProps> = ({
canvas.style.top = '0px';
canvas.style.left = '0px';
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = zIndex ? zIndex.toString() : '';

if (wrapperElement) {
canvas.style.position = 'absolute';
Expand Down
3 changes: 3 additions & 0 deletions registry/components/cursor/common/rainbow-cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface RainbowCursorProps {
pulseSpeed?: number;
pulseMin?: number;
pulseMax?: number;
zIndex?: number;
}

const RainbowCursor: React.FC<RainbowCursorProps> = ({
Expand All @@ -27,6 +28,7 @@ const RainbowCursor: React.FC<RainbowCursorProps> = ({
pulseSpeed = 0.01,
pulseMin = 0.8,
pulseMax = 1.2,
zIndex
}) => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const contextRef = useRef<CanvasRenderingContext2D | null>(null);
Expand Down Expand Up @@ -99,6 +101,7 @@ const RainbowCursor: React.FC<RainbowCursorProps> = ({
canvas.style.left = '0px';
canvas.style.pointerEvents = 'none';
canvas.style.position = hasWrapperEl ? 'absolute' : 'fixed';
canvas.style.zIndex = zIndex ? zIndex.toString() : '';

if (hasWrapperEl) {
element?.appendChild(canvas);
Expand Down
4 changes: 3 additions & 1 deletion registry/components/cursor/common/snowflake-cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import React, { useEffect, useRef } from 'react';

interface SnowflakeCursorOptions {
element?: HTMLElement;
zIndex?: number;
}

const SnowflakeCursor: React.FC<SnowflakeCursorOptions> = ({ element }) => {
const SnowflakeCursor: React.FC<SnowflakeCursorOptions> = ({ element, zIndex }) => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const particles = useRef<any[]>([]);
const canvImages = useRef<HTMLCanvasElement[]>([]);
Expand All @@ -32,6 +33,7 @@ const SnowflakeCursor: React.FC<SnowflakeCursorOptions> = ({ element }) => {
canvas.style.top = '0';
canvas.style.left = '0';
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = zIndex ? zIndex.toString() : '';

targetElement.appendChild(canvas);
canvasRef.current = canvas;
Expand Down
3 changes: 3 additions & 0 deletions registry/components/cursor/common/springy-cursor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import React, { useEffect, useRef } from 'react';
interface SpringyCursorProps {
emoji?: string;
wrapperElement?: HTMLElement;
zIndex?: number;
}

const SpringyCursor: React.FC<SpringyCursorProps> = ({
emoji = '⚽',
wrapperElement,
zIndex,
}) => {
const canvasRef = useRef<HTMLCanvasElement | null>(null);
const particlesRef = useRef<any[]>([]);
Expand Down Expand Up @@ -52,6 +54,7 @@ const SpringyCursor: React.FC<SpringyCursorProps> = ({
canvas.style.top = '0px';
canvas.style.left = '0px';
canvas.style.pointerEvents = 'none';
canvas.style.zIndex = zIndex ? zIndex.toString() : '';

if (wrapperElement) {
canvas.style.position = 'absolute';
Expand Down