Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. function getRandomInt(min, max) {
  2. return Math.floor(Math.random() * (max - min + 1)) + min;
  3. }
  4.  
  5. function getPositionOfWinner(winner) {
  6. var widthOfImg = $('#roulette-img1').width();
  7. var minDistanceToEdgeAllowed = 2;
  8.  
  9. var desiredImg = $('#roulette-img' + winner.toString());
  10.  
  11. var minPos = desiredImg.position().left + minDistanceToEdgeAllowed;
  12. var maxPos = desiredImg.position().left + widthOfImg - minDistanceToEdgeAllowed;
  13.  
  14. return getRandomInt(minPos, maxPos);
  15. }
  16.  
  17. function timelineFinished(destImg) {
  18. ion.sound.play("pop_cork"), $("#roulette-img" + destImg).css("box-shadow", "rgb(18, 18, 19) 0px 3px 16px 3px"), clearInterval(spin_sound), setTimeout(function() {
  19. window.mainModal.showModal(), window.stateRulet = 1
  20. }, 600)
  21. }
  22.  
  23. function rouletteSpin(destImg) {
  24. if (!destImg) destImg = 40;
  25. var tl = new TimelineMax({
  26. onComplete: timelineFinished,
  27. onCompleteParams: [ destImg ]
  28. }),
  29. rouletteImages = $('#roulette-images-list'),
  30. startLeft = rouletteImages.position().left;
  31.  
  32. //Заготовка для звукового эффекта
  33. current = Math.floor(startLeft-197)
  34. spin_sound = setInterval(function()
  35. {
  36. if (current > Math.floor($('#roulette-images-list').position().left))
  37. {;
  38. ion.sound.play("snap");
  39. current -= 197;
  40. //console.log(current)
  41. }
  42. }, 20);
  43. //Заготовка для звукового эффекта
  44.  
  45.  
  46. tl.to(rouletteImages, 7, {x: getPositionOfWinner(destImg) * -1, ease: Power1. easeInOut});
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement