Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getRandomInt(min, max) {
- return Math.floor(Math.random() * (max - min + 1)) + min;
- }
- function getPositionOfWinner(winner) {
- var widthOfImg = $('#roulette-img1').width();
- var minDistanceToEdgeAllowed = 2;
- var desiredImg = $('#roulette-img' + winner.toString());
- var minPos = desiredImg.position().left + minDistanceToEdgeAllowed;
- var maxPos = desiredImg.position().left + widthOfImg - minDistanceToEdgeAllowed;
- return getRandomInt(minPos, maxPos);
- }
- function timelineFinished(destImg) {
- ion.sound.play("pop_cork"), $("#roulette-img" + destImg).css("box-shadow", "rgb(18, 18, 19) 0px 3px 16px 3px"), clearInterval(spin_sound), setTimeout(function() {
- window.mainModal.showModal(), window.stateRulet = 1
- }, 600)
- }
- function rouletteSpin(destImg) {
- if (!destImg) destImg = 40;
- var tl = new TimelineMax({
- onComplete: timelineFinished,
- onCompleteParams: [ destImg ]
- }),
- rouletteImages = $('#roulette-images-list'),
- startLeft = rouletteImages.position().left;
- //Заготовка для звукового эффекта
- current = Math.floor(startLeft-197)
- spin_sound = setInterval(function()
- {
- if (current > Math.floor($('#roulette-images-list').position().left))
- {;
- ion.sound.play("snap");
- current -= 197;
- //console.log(current)
- }
- }, 20);
- //Заготовка для звукового эффекта
- tl.to(rouletteImages, 7, {x: getPositionOfWinner(destImg) * -1, ease: Power1. easeInOut});
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement