Advertisement
Guest User

Untitled

a guest
Jul 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // auto visible img
  2. $(function () {
  3. var change_img_time = 5000;
  4. var transition_speed = 300;
  5.  
  6. var simple_slideshow = $(".photo-switch"),
  7. listItems = simple_slideshow.children('img'),
  8. listLen = listItems.length,
  9. i = 0,
  10.  
  11. changeList = function () {
  12.  
  13. listItems.eq(i).fadeOut(transition_speed, function () {
  14. i ++;
  15. if (i === listLen) {
  16. i = 0;
  17.  
  18. }
  19. listItems.eq(i).fadeIn(transition_speed);
  20.  
  21. });
  22.  
  23. };
  24.  
  25. listItems.not(':first').hide();
  26. count = 0;
  27.  
  28. intervalId = setInterval(function(){
  29. count++;
  30. if(count === 2){
  31. clearInterval(intervalId);
  32. }
  33. changeList();
  34. }, change_img_time);
  35. });
  36. // auto visible img end
  37.  
  38. // click img
  39. $(document).ready(function () {
  40. var penImg = $('.photo-switch img');
  41.  
  42. $('.photo-switch > .btn-click').on('click', function () {
  43. $('.photo-switch > .btn-click').removeClass('btn-on');
  44. $(this).addClass('btn-on');
  45. var imgPath;
  46.  
  47. imgPath = $(this).attr('data-img-path');
  48.  
  49. penImg.attr('src', imgPath);
  50.  
  51. });
  52.  
  53.  
  54. });
  55. // click img end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement