Guest User

Untitled

a guest
Mar 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. var slideIndex = 0;
  2. var slides = document.getElementsByClassName("Slides");
  3. var dots = document.getElementsByClassName("dot");
  4. //I thought that maybe the error originated here so I triple checked everything here
  5.  
  6. showSlides();
  7.  
  8. function showSlides() {
  9. var i;
  10. for (i = 0; i < slides.length; i++) {
  11. if (slides[i].style.transform == "translateX(100%)") {
  12. slides[i].style.display = "none";
  13. //make sure slide that's about to be replaced doesn't interfere with next one.
  14. }
  15. slides[i].style.transform = "translateX(-100%)";
  16. //return all slides to -100% position. (Is already an issue because current
  17. //slide is supposed to move to the right but it'll jump. I'll figure this out,
  18. //this is NOT my question)
  19. }
  20. //??Error here. I know the line is empty I don't understand it neither??
  21. //Maybe it's the previous 'for' loop?
  22.  
  23. slides[slideIndex - 1].style.transform = "translateX(100%)";
  24. //Move old slide 100%.
  25. slideIndex++;
  26. //Next Slide
  27. if (slideIndex > slides.length) { slideIndex = 1; }
  28. else if (slideIndex < 0) { slideIndex = slides.length; }
  29. //Self-explanatory
  30. slides[slideIndex - 1].style.display = "inline-block";
  31. slides[slideIndex - 1].style.transform = "translateX(0)";
  32. dots[slideIndex - 1].className += " active";
  33. //Move new slide in and activate concurrent dot
  34. if (slideIndex == 1) {
  35. setTimeout(showSlides(), 10000);
  36. }
  37. // I want the first picture to last longer
  38. else {
  39. setTimeout(showSlides(), 5000)
  40. }
  41. }
  42.  
  43. <div class="Slides">
  44. <img src="~/Images/Slideshow/Gallery-1.jpg" class="Slides-Images">
  45. </div>
  46.  
  47. <div class="Slides">
  48. <img src="~/Images/Slideshow/Gallery-2.jpg" class="Slides-Images">
  49. </div>
  50.  
  51. <div class="Slides">
  52. <img src="~/Images/Slideshow/Gallery-3.jpg" class="Slides-Images">
  53. </div>
  54.  
  55. .Slides {
  56. position: absolute;
  57. transition: transform 2s;
  58. width: 100%;
  59. height: 100%;
  60. margin: 0;
  61. }
Add Comment
Please, Sign In to add comment