script.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. var $positionAbsolute = $('#absolute').addClass('hide');
  2. var $item = $('.hide-button').data('counter', 1);
  3. var $changeBgPreviosly = $('#change-bg-previous');
  4. var $changeBgNext = $('#change-bg-next');
  5. var arr = [
  6. {
  7. 'background': 'url(img/combo.jpg)',
  8. 'background-color': 'rgba(0,0,0,0.3)',
  9. 'background-blend-mode': 'multiply',
  10. 'background-position': 'center',
  11. 'background-repeat': 'no-repeat'
  12. },
  13. {
  14. 'background': 'url(img/combo1.jpg)',
  15. 'background-color': 'rgba(0,0,0,0.3)',
  16. 'background-blend-mode': 'multiply',
  17. 'background-position': 'center',
  18. 'background-repeat': 'no-repeat'
  19. },
  20. {
  21. 'background': 'url(img/combo2.jpg)',
  22. 'background-color': 'rgba(0,0,0,0.3)',
  23. 'background-blend-mode': 'multiply',
  24. 'background-position': 'center',
  25. 'background-repeat': 'no-repeat'
  26. },
  27. {
  28. 'background': 'url(img/combo3.jpg)',
  29. 'background-color': 'rgba(0,0,0,0.3)',
  30. 'background-blend-mode': 'multiply',
  31. 'background-position': 'center',
  32. 'background-repeat': 'no-repeat'
  33. },
  34. {
  35. 'background': 'url(img/combo4.jpg)',
  36. 'background-color': 'rgba(0,0,0,0.3)',
  37. 'background-blend-mode': 'multiply',
  38. 'background-position': 'center',
  39. 'background-repeat': 'no-repeat'
  40. },
  41. {
  42. 'background': 'url(img/combo.jpg)',
  43. 'background-color': 'rgba(0,0,0,0.3)',
  44. 'background-blend-mode': 'multiply',
  45. 'background-position': 'center',
  46. 'background-repeat': 'no-repeat'
  47. },
  48. ];
  49. var $background = $('#bg').css(arr[0]);
  50. var carousel = setInterval(function() {
  51. $background.css(arr[ Math.floor((Math.random() * 5) + 1) ]);
  52. }, 8000);
  53. $item.on('click', function(event) {
  54. event.preventDefault();
  55. var counter = $item.data('counter');
  56. $item.data('counter', counter + 1);
  57. if (counter !== 0) {
  58. $positionAbsolute.removeClass('hide').addClass('show').text(counter);
  59. }
  60. });
  61. $changeBgPreviosly.on('click', function(){
  62. event.preventDefault();
  63. $background.css(arr[ Math.floor((Math.random() * 5) + 1) ]);
  64. });
  65. $changeBgNext.on('click', function(){
  66. event.preventDefault();
  67. $background.css(arr[ Math.floor((Math.random() * 5) + 1) ]);
  68. });
  69. $(window).scroll(function(){
  70. if ($(this).scrollTop() > 200) {
  71. $('.scrollup').fadeIn();
  72. } else {
  73. $('.scrollup').fadeOut();
  74. }
  75. });
  76. $('.scrollup').click(function(){
  77. $("html, body").animate({ scrollTop: 0 }, 600);
  78. });