Home Forums WoodMart support forum OWL Carousel

OWL Carousel

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #37282

    MoeMauphie
    Participant

    Hi there,

    Is there an easy way to enable “center” mode in sliders? Please check this demo page:
    https://owlcarousel2.github.io/OwlCarousel2/demos/center.html
    I think this mode comes really handy specially on mobile devices, because it lets viewers know that there are more items and they just need to swipe to see them. By using this, we won’t need those ugly arrows too.

    As you might have noticed, Google also uses a very similar method to display images in search results, but the only difference is that in Google, scrolling is totally free and it doesn’t slide to definite locations as you swipe. This is also a nice feature and I don’t know if it’s possible with OWL carousel or not. (digikala.com also uses the Google’s method)

    What would you think? Can we have either of the two in WOODMART?

    Regards,

    Moe

    Attachments:
    You must be logged in to view attached files.
    #37305

    Artem Temos
    Keymaster

    Hi,

    Could you please specify for which carousel do you want to apply this option? And note that it can’t be set for mobile devices only. As you can see in OWL demo, it works for both desktop and mobile devices.

    Regards

    #37377

    MoeMauphie
    Participant

    Thanks for your reply,

    Basically that would be great if you could have that functionality for all the carousels available on the theme like Products (grid and carousel), Ajax Products Tabs and also Related Products. Now there are options for the number of columns etc, it would be nice to have an option for the style of carousel as well.

    Regards,

    #37464

    Artem Temos
    Keymaster

    Try to add the following PHP code snippet to the child theme functions.php file to do this

    function woodmart_owl_carousel_init( $atts = array() ) {
    		extract( shortcode_atts( woodmart_get_owl_atts(), $atts ) );
    
    		$func_name = 'carousel_' . $carousel_id;
    		$func_name = function() use( $carousel_id, $slides_per_view, $autoplay, $autoheight, $speed, $hide_pagination_control, $hide_prev_next_buttons, $scroll_per_page, $wrap, $dragEndSpeed  ) {
    			
    			$items = woodmart_get_owl_items_numbers( $slides_per_view );
    			ob_start();
    			?>
    
    				jQuery( document ).ready(function( $ ) {
    
    	                var owl = $("#<?php echo esc_js( $carousel_id ); ?> .owl-carousel");
    
    					$( window ).bind( "vc_js", function() {
    						owl.trigger('refresh.owl.carousel');
    					} );
    
    					var options = {
    	            		rtl: $('body').hasClass('rtl'),
    			            items: <?php echo esc_js( $items['desktop'] ); ?>, 
    			            responsive: {
    			            	979: {
    			            		items: <?php echo esc_js( $items['desktop'] ); ?>
    			            	},
    			            	768: {
    			            		items: <?php echo esc_js( $items['desktop_small'] ); ?>
    			            	},
    			            	479: {
    			            		items: <?php echo esc_js( $items['tablet'] ); ?>
    			            	},
    			            	0: {
    			            		items: <?php echo esc_js( $items['mobile'] ); ?>
    			            	}
    			            },
    						center: true,
    			            autoplay: <?php echo ($autoplay == 'yes') ? 'true' : 'false'; ?>,
    						autoplayHoverPause: <?php echo apply_filters( 'woodmart_autoplay_hover_pause', 'true' ); ?>,	
    			            autoplayTimeout: <?php echo esc_js( $speed ); ?>,
    			            dots: <?php echo ($hide_pagination_control == 'yes') ? 'false' : 'true'; ?>,
    			            nav: <?php echo ($hide_prev_next_buttons == 'yes') ? 'false' : 'true'; ?>,
    			            autoheight: <?php echo ($autoheight == 'yes') ? 'false' : 'true'; ?>,
    			            slideBy:  <?php echo ($scroll_per_page == 'yes') ? '\'page\'' : 1; ?>,
    			            navText:false,
    			            loop: true,
    						dragEndSpeed: <?php echo esc_js( $dragEndSpeed ); ?>,
    			            onRefreshed: function() {
    			            	$(window).resize();
    			            }
    					};
    
    	                owl.owlCarousel(options);
    
    				});
    			<?php
    			return ob_get_clean();
    		};
    
    		if( $carousel_js_inline == 'yes' ) {
    			echo '<script type="text/javascript">' . $func_name() . '</script>';
    		} else {
        		wp_add_inline_script( 'woodmart-theme', $func_name(), 'after' );
    		}
    	}
    #37504

    MoeMauphie
    Participant

    Thanks a lot for your help,

    For the related products carousel, we have to set “Related product columns” to 6 in order to show more than one product in mobile devices, I think that would be nice to have an option to choose columns in mobile devices separately.

    Thanks,

    #37513

    Artem Temos
    Keymaster

    Try to replace this code

    items: <?php echo esc_js( $items['mobile'] ); ?>

    with this for example

    items: 2

    #37536

    MoeMauphie
    Participant

    Thanks a lot,

    #37546

    Artem Temos
    Keymaster

    You are welcome.

Viewing 8 posts - 1 through 8 (of 8 total)