I am working on Winwheel.js for draw. Everything works fine but I’m stuck somewhere. When the wheel is turned, I get some datas with axios from back and the result is determined. I want to use this response when the wheel is stopped, I tried many of things but I didn’t do it.
let theWheel = new Winwheel({
//wheel settings//
'segments' :
[
{'fillStyle' : '#008000', 'text' : '150 Coin', 'textFontSize' : 13, 'textFillStyle' : '#ffffff'},
...,
],
'animation' :
{
'type' : 'spinToStop',
'duration' : 10,
'spins' : 3,
'callbackFinished' : alertPrize,
'callbackSound' : playSound,
'soundTrigger' : 'pin'
},
'pins' : // Turn pins on.
{
'number' : 10,
'fillStyle' : 'silver',
'outerRadius': 4,
}
});
async function calculatePrize(){
let result = await axios.post("/draw-reward-win-wheel/", {}).then((response) => {
let stopAt;
if(response.data.text == '150') stopAt = (1 + Math.floor((Math.random() * 30)));
//Other possibilities
theWheel.animation.stopAngle = stopAt;
theWheel.startAnimation();
}).catch((err) => {
console.log(err);
});
}
async function alertPrize(code)
{
//I need response.data.text here
}