2.1.0 • Published 9 months ago

wheel-fortune v2.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

npm GitHub package version NPM Downloads

1kB gzipped

Demo

Install

$ yarn add wheel-fortune

Import

import WheelFortune from 'wheel-fortune';

Usage

const spinStates = [
  { stopSegment: 5, callback: () => console.log('first spin end') },
  { stopSegment: 2, callback: () => console.log('second spin end') },
  ...
];

const wheel = new WheelFortune({
  spinStates: spinStates,
  rotationCount: 4,
  segmentCount: 8,
});

wheel.init();

Options

OptionTypeDefaultDescription
containerElstring | HTMLElement.wheelThis parameter references a DOM element that acts as a container for the entire wheel of fortune. It is used to apply common styles and animations, such as blurring --blurring and changing transparency --blackout-opacity, which affect the entire component during and between spins of the wheel.
segmentsElstring | HTMLElement.wheel__segmentsThe parameter references the DOM element containing the segments of the wheel of fortune.
buttonElstring | HTMLElement.wheel__buttonThe parameter references the DOM element of the button that initiates the wheel spin.
rotationCountnumber3This parameter determines the number of full revolutions of the wheel before it stops on the last segment.
segmentCountnumber8This parameter defines the total number of segments on the wheel. It is used to calculate the angle of each segment (360° divided by the number of segments) and to determine the final position of the wheel after rotation.
spinStatesArray<{stopSegment: number, callback: Function}>[]The parameter contains an array of objects, each describing a different state of wheel rotation, including a stop segment and a colback that can be called after the wheel has stopped.
wheelLibrationBooleanfalseThis parameter determines whether the visual element of the wheel will simulate libration (a slight wobble around its axis) when at rest. If set to true, the wheel will wobble slightly to the left and right.
HTML classDescription
.is-spinningThis class is added to the wheel container element at the start of the rotation and removed when the rotation is complete.
.end-last-spinThis class is added to the wheel container element after the last revolution of a series of revolutions has been completed.

License

wheel-fortune is released under MIT license

1.5.5

9 months ago

1.5.4

9 months ago

1.5.3

9 months ago

1.5.2

9 months ago

2.1.0

9 months ago

2.0.0

9 months ago

1.4.4

1 year ago

1.4.3

1 year ago

1.5.1

1 year ago

1.4.2

1 year ago

1.5.0

1 year ago

1.4.1

1 year ago

1.4.0

1 year ago

1.3.0

1 year ago

1.2.0

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.1-alpha.8

1 year ago

0.0.1-alpha.7

1 year ago

0.0.1-alpha.6

1 year ago

0.0.1-alpha.5

1 year ago

0.0.1-alpha.4

1 year ago

0.0.1-alpha.3

1 year ago

0.0.1-alpha.2

1 year ago

0.0.1-alpha.1

1 year ago