npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gluecksrad

v1.1.1

Published

A beautiful, customizable lottery wheel component for React applications

Readme

Gluecksrad

A highly customizable, reusable wheel component with advanced rotation animation capabilities and external control.

Demo

Check out the live demo to see the wheel in action!

Features

  • 🎯 External Control: Public spin() function for programmatic control
  • ⚙️ Configurable Animation: Duration, rotations, and easing customization
  • 📡 Rich Callbacks: onSpinStart, onSpinning, onSpinComplete events
  • 🔄 State Management: Maintains rotation state across multiple spins
  • 🎨 Fully Customizable: Colors, sizes, and visual elements
  • 📱 TypeScript Support: Complete type safety and IntelliSense
  • 🎪 Smooth Animations: Powered by Anime.js

Installation

npm install gluecksrad

Basic Usage

import React, { useRef } from 'react';
import { Wheel, type WheelRef } from 'gluecksrad';

const segments = [
  { id: 1, name: '$1000', color: '#6366F1' },
  { id: 2, name: '$500', color: '#8B5CF6' },
  { id: 3, name: '$250', color: '#EC4899' },
  { id: 4, name: '$100', color: '#EF4444' },
];

function BasicExample() {
  const wheelRef = useRef<WheelRef>(null);

  const handleSpin = async () => {
    if (wheelRef.current) {
      const result = await wheelRef.current.spin();
      console.log('Winner:', result.winningSegment);
    }
  };

  return (
    <div>
      <Wheel
        ref={wheelRef}
        segments={segments}
        onSpinComplete={(angle, winner) => {
          console.log('Spin complete!', winner);
        }}
      />
      <button onClick={handleSpin}>Spin Wheel</button>
    </div>
  );
}

Advanced Usage

import React, { useRef, useState } from 'react';
import { Wheel, type WheelRef, type WheelRotationParams } from 'gluecksrad';

const segments = [
  { id: 1, name: '$1000', color: '#6366F1' },
  { id: 2, name: '$500', color: '#8B5CF6' },
  { id: 3, name: '$250', color: '#EC4899' },
  { id: 4, name: '$100', color: '#EF4444' },
];

function AdvancedExample() {
  const wheelRef = useRef<WheelRef>(null);
  const [currentAngle, setCurrentAngle] = useState(0);
  const [isSpinning, setIsSpinning] = useState(false);

  const customSpin = async () => {
    if (!wheelRef.current) return;

    const params: WheelRotationParams = {
      duration: 5, // 5 seconds
      rotations: 4, // 4 full rotations
      easing: 'easeOutElastic(1, .8)',
      finalAngle: 45 // Stop at 45 degrees
    };

    const result = await wheelRef.current.spin(params);
    console.log('Custom spin result:', result);
  };

  const resetWheel = () => {
    wheelRef.current?.reset();
  };

  const setSpecificAngle = () => {
    wheelRef.current?.setAngle(90); // Set to 90 degrees
  };

  return (
    <div>
      <Wheel
        ref={wheelRef}
        segments={segments}
        size={500}
        defaultRotationParams={{
          duration: 3,
          rotations: 2,
          easing: 'easeOutCubic'
        }}
        onSpinStart={() => {
          console.log('Spin started!');
          setIsSpinning(true);
        }}
        onSpinning={(angle) => {
          setCurrentAngle(angle);
        }}
        onSpinComplete={(angle, winner) => {
          console.log('Spin completed!', winner);
          setIsSpinning(false);
        }}
      />

      <div>
        <p>Current Angle: {currentAngle.toFixed(2)}°</p>
        <p>Is Spinning: {isSpinning ? 'Yes' : 'No'}</p>
      </div>

      <div>
        <button onClick={customSpin}>Custom Spin</button>
        <button onClick={resetWheel}>Reset</button>
        <button onClick={setSpecificAngle}>Set to 90°</button>
      </div>
    </div>
  );
}

API Reference

WheelRef Methods

interface WheelRef {
  // Spin the wheel with optional parameters
  spin(params?: WheelRotationParams): Promise<{
    finalAngle: number;
    winningSegment?: WheelSegment;
  }>;

  // Get current rotation angle
  getCurrentAngle(): number;

  // Check if wheel is currently spinning
  isSpinning(): boolean;

  // Reset wheel to initial position
  reset(): void;

  // Set wheel to specific angle (only when not spinning)
  setAngle(angle: number): void;
}

WheelRotationParams

interface WheelRotationParams {
  duration?: number;     // Duration in seconds (default: 4)
  rotations?: number;    // Number of full rotations (default: 3-6 random)
  easing?: string;       // Anime.js easing function (default: 'easeOutCubic')
  finalAngle?: number;   // Specific final angle (default: random)
}

Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | segments | WheelSegment[] | Required | Array of wheel segments | | size | number | 400 | Wheel diameter in pixels | | className | string | '' | Additional CSS classes | | style | React.CSSProperties | {} | Inline styles | | centerCircleColor | string | 'rgba(255,255,255,0.2)' | Center circle color | | pointerColor | string | '#FFFFFF' | Pointer color | | textColor | string | '#FFFFFF' | Text color | | borderColor | string | 'rgba(255,255,255,0.15)' | Border color | | showBorder | boolean | true | Show segment borders | | showPointer | boolean | true | Show pointer | | defaultRotationParams | WheelRotationParams | {} | Default rotation settings | | disabled | boolean | false | Disable wheel spinning | | initialAngle | number | 0 | Initial rotation angle |

Callbacks

| Callback | Type | Description | |----------|------|-------------| | onSpinStart | () => void | Called when spin begins | | onSpinning | (currentAngle: number) => void | Called during rotation | | onSpinComplete | (finalAngle: number, winningSegment?: WheelSegment) => void | Called when spin ends |

Animation Easing Options

  • 'linear'
  • 'easeInQuad', 'easeOutQuad', 'easeInOutQuad'
  • 'easeInCubic', 'easeOutCubic', 'easeInOutCubic'
  • 'easeInElastic', 'easeOutElastic', 'easeInOutElastic'
  • Custom cubic-bezier functions

Examples

Programmatic Control

// Spin with custom parameters
await wheelRef.current?.spin({
  duration: 6,
  rotations: 5,
  easing: 'easeOutBounce'
});

// Get current state
const angle = wheelRef.current?.getCurrentAngle();
const spinning = wheelRef.current?.isSpinning();

Event Handling

<Wheel
  segments={segments}
  onSpinStart={() => console.log('Started!')}
  onSpinning={(angle) => console.log(`Angle: ${angle}`)}
  onSpinComplete={(angle, winner) => console.log('Winner:', winner)}
/>

License

MIT License