Home › Forums › WoodMart support forum › OWL Carousel
OWL Carousel
- This topic has 7 replies, 2 voices, and was last updated 6 years, 10 months ago by Artem Temos.
-
AuthorPosts
-
February 4, 2018 at 9:10 am #37282
MoeMauphieParticipantHi 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.February 4, 2018 at 11:24 am #37305
Artem TemosKeymasterHi,
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
February 4, 2018 at 5:26 pm #37377
MoeMauphieParticipantThanks 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,
February 5, 2018 at 8:35 am #37464
Artem TemosKeymasterTry 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' ); } }
February 5, 2018 at 12:26 pm #37504
MoeMauphieParticipantThanks 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,
February 5, 2018 at 12:47 pm #37513
Artem TemosKeymasterTry to replace this code
items: <?php echo esc_js( $items['mobile'] ); ?>
with this for example
items: 2
February 5, 2018 at 1:49 pm #37536
MoeMauphieParticipantThanks a lot,
February 5, 2018 at 2:06 pm #37546
Artem TemosKeymasterYou are welcome.
-
AuthorPosts
- You must be logged in to create new topics. Login / Register