Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function 1() {
  2. let firstChild = $('.carousel > div:first-child');
  3. firstChild.remove();
  4. }
  5.  
  6. function 2() {
  7. $('.carousel').children().each(function() {
  8. let left = parseInt($(this).attr('style').slice(6, -2)) - 10;
  9. $(this).css('left', `${left}vw`);
  10. });
  11. }
  12.  
  13. function previousSlide() {
  14. 1();
  15.  
  16. $('.carousel').append(firstChild);
  17. $('.carousel > div:last-child').attr('style', `left: ${$('.carousel').children().length * 10 - 10}vw`);
  18.  
  19. 2();
  20. }
  21.  
  22. function nextSlide() {
  23. 1();
  24.  
  25. $('.carousel').prepend(lastChild);
  26. $('.carousel > div:first-child').attr('style', 'left: -10vw;');
  27.  
  28. 2();
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement