npm install lottery-wheel
Or download the latest Release.
Usage
Install the package via npm:
API
Please visit repo
to see guides.
Basic Examples
Show the drawn prize:
new Wheel({
el: document.getElementById('wheel1'),
data: ['prize A', 'prize B', 'prize C', 'prize D'],
onSuccess(data) {
alert(data.text);
}
});
Prizes with different probability to be drawn:
new Wheel({
el: document.getElementById('wheel2'),
data: [{
text: '50%',
chance: 5
}, {
text: '20%',
chance: 2
}, '10%', '10%', '10%']
});
Can only draw one time:
new Wheel({
el: document.getElementById('wheel3'),
data: ['prize A', 'prize B', 'prize C', 'prize D'],
limit: 1,
onFail() {
alert('You have no more chance to draw');
}
});
Custom styles:
new Wheel({
el: document.getElementById('wheel4'),
data: [{
text: 'Beijing',
color: 'silver',
fontSize: 24
}, {
text: 'London',
fontColor: '#008000'
}, 'New York', 'Tokyo'],
theme: 'light',
radius: 150,
buttonWidth: 75,
color: {
button: '#fef5e7',
buttonFont: '#34495e'
}
});