Loop Image Carousel

I'm using Image Carousel in WP bakery but it is not pretty that there is empty/white space when you scroll to the last picture. I've check "Slider loop" but the only thing that happends is that when you have showed the last picture, the whole carousel starts over again. Isn't there a why to always shows eg three picture and no white/empty space?


Comments

  • Hi,

    Please always attach a link to your website so we can check it out. If the page is offline(localhost), then our help will be limited. You will have to contact us when the page is online. Also, please make sure that the page is not under maintenance before you provide us with the link.

    Thanks

  • I've solved it by this fix:


    1. /*
    2. Turn Visual Composer Image Carousel into Visual Composer Infinite Image Carousel
    3. Include before the </head> tag on yout theme's header.php
    4. Read the detailed step-by-step at https://humbertosilva.com/visual-composer-infinite-image-carousel/
    5. */
    6.  
    7. // auxiliary code to create triggers for the add and remove class for later use
    8. (function($){
    9. $.each(["addClass","removeClass"],function(i,methodname){
    10. var oldmethod = $.fn[methodname];
    11. $.fn[methodname] = function(){
    12. oldmethod.apply( this, arguments );
    13. this.trigger(methodname+"change");
    14. return this;
    15. }
    16. });
    17. })(jQuery);
    18.  
    19. // main function for the infinite loop
    20. function vc_custominfiniteloop_init(vc_cil_element_id){
    21.  
    22. var vc_element = '#' + vc_cil_element_id; // because we're using this more than once let's create a variable for it
    23. window.maxItens = jQuery(vc_element).data('per-view'); // max visible items defined
    24. window.addedItens = 0; // auxiliary counter for added itens to the end
    25.  
    26. // go to slides and duplicate them to the end to fill space
    27. jQuery(vc_element).find('.vc_carousel-slideline-inner').find('.vc_item').each(function(){
    28. // we only need to duplicate the first visible images
    29. if (window.addedItens < window.maxItens) {
    30. if (window.addedItens == 0 ) {
    31. // the fisrt added slide will need a trigger so we know it ended and make it "restart" without animation
    32. jQuery(this).clone().addClass('vc_custominfiniteloop_restart').removeClass('vc_active').appendTo(jQuery(this).parent());
    33. } else {
    34. jQuery(this).clone().removeClass('vc_active').appendTo(jQuery(this).parent());
    35. }
    36. window.addedItens++;
    37. }
    38. });
    39.  
    40. // add the trigger so we know when to "restart" the animation without the user knowing about it
    41. jQuery('.vc_custominfiniteloop_restart').bind('addClasschange', null, function(){
    42.  
    43. // navigate to the carousel element , I know, its ugly ...
    44. var vc_carousel = jQuery(this).parent().parent().parent().parent();
    45.  
    46. // first we temporarily change the animation speed to zero
    47. jQuery(vc_carousel).data('vc.carousel').transition_speed = 0;
    48.  
    49. // make the slider go to the first slide without animation and because the fist set of images shown
    50. // are the same that are being shown now the slider is now "restarted" without that being visible
    51. jQuery(vc_carousel).data('vc.carousel').to(0);
    52.  
    53. // allow the carousel to go to the first image and restore the original speed
    54. setTimeout("vc_cil_restore_transition_speed('"+jQuery(vc_carousel).prop('id')+"')",100);
    55. });
    56.  
    57. }
    58.  
    59. // restore original speed setting of vc_carousel
    60. function vc_cil_restore_transition_speed(element_id){
    61. // after inspecting the original source code the value of 600 is defined there so we put back the original here
    62. jQuery('#' + element_id).data('vc.carousel').transition_speed = 600;
    63. }
    64.  
    65. // init
    66. jQuery(document).ready(function(){
    67. // find all vc_carousel with the defined class and turn them into infine loop
    68. jQuery('.vc_custominfiniteloop').find('div[data-ride="vc_carousel"]').each(function(){
    69. // allow time for the slider to be built on the page
    70. // because the slider is "long" we can wait a bit before adding images and events needed
    71. var vc_cil_element = jQuery(this).prop("id");
    72. setTimeout("vc_custominfiniteloop_init('"+vc_cil_element+"')",2000);
    73. });
    74. });
    75.  


Sign In or Register to comment.