0.1.4 • Published 3 years ago

react-spinning-canvas-wheel v0.1.4

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

React Spinning Canvas Wheel

Wheel

Features

  • Zero dependencies
  • Written in TypeScript
  • High DPI screens support
  • SSR support
  • Customizable timing function

Installation

npm i react-spinning-canvas-wheel
yarn add react-spinning-canvas-wheel

Usage

import { useRef } from 'react';
import SpinningWheel, {
  SpinningWheelRef,
  WheelSegment,
} from 'react-spinning-canvas-wheel';

const SEGMENTS: WheelSegment[] = [
  { title: 'Metal Gear Solid' },
  { title: 'Dark Souls 2' },
  { title: 'Escape From Tarkov' },
  { title: 'It Takes Two' },
  { title: 'Resident Evil Village' },
];

const Wheel = () => {
  const spinningWheelRef = useRef<SpinningWheelRef>();

  return (
    <div>
      {/* startSpinning(secondsToSpin: number, speed: number) */}
      <button onClick={() => spinningWheelRef.current.startSpinning(30, 4)}>
        Start
      </button>
      <button onClick={() => spinningWheelRef.current.stopSpinning()}>
        Stop
      </button>
      <SpinningWheel
        size={640}
        segments={SEGMENTS}
        spinningWheelRef={spinningWheelRef}
        onSegmentChange={(index) => console.log('currentSegmentIndex:', index)}
        onSpinStart={() => console.log('started')}
        onSpinEnd={(winnerIndex) => console.log('winnerIndex:', winnerIndex)}
      />
    </div>
  );
};
0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago