Home Forums WoodMart support forum Show Sidebar Trigger Code

Show Sidebar Trigger Code

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #27738

    newsprince
    Participant

    Hello.

    Can you provide us with the code to trigger and show the off canvas sidebar in shop page?

    We want to create a custom button and assign to that button the functionality to open the sidebar when someone press it.

    I tried to assign the class “woodmart-show-sidebar-btn” to a button or menu item but i think there is some JS code involved too.

    Can you help us?

    Thanks.

    #27756

    Artem Temos
    Keymaster

    Hi,

    Here is a JavaScript code to show the hidden sidebar

    $('.sidebar-container').addClass('show-hidden-sidebar');
    $('body').addClass('woodmart-show-hidden-sidebar');
    $('.woodmart-show-sidebar-btn').addClass('btn-clicked');
    
    if( $(window).width() >= 1024 ) {
        $(".sidebar-inner.woodmart-sidebar-scroll").nanoScroller({
            paneClass: 'woodmart-scroll-pane',
            sliderClass: 'woodmart-scroll-slider',
            contentClass: 'woodmart-sidebar-content',
            preventPageScrolling: false
        });
    }

    Regards

    #27783

    newsprince
    Participant

    Thank you very much.

    What class i have to put on button element or text etc to make trigger this code?

    #27811

    newsprince
    Participant

    Can you help me implement this code on a button?

    #27827

    Artem Temos
    Keymaster

    Hi,

    Try this code

    
    $('.open-sidebar-btn').click(function() {
    $('.sidebar-container').addClass('show-hidden-sidebar');
    $('body').addClass('woodmart-show-hidden-sidebar');
    $('.woodmart-show-sidebar-btn').addClass('btn-clicked');
    
    if( $(window).width() >= 1024 ) {
        $(".sidebar-inner.woodmart-sidebar-scroll").nanoScroller({
            paneClass: 'woodmart-scroll-pane',
            sliderClass: 'woodmart-scroll-slider',
            contentClass: 'woodmart-sidebar-content',
            preventPageScrolling: false
        });
    }
    });

    And then add open-sidebar-btn class to your button.

    Regards

    #27851

    newsprince
    Participant

    It works! Thanks

    #27864

    Artem Temos
    Keymaster

    You are welcome!

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

The topic ‘Show Sidebar Trigger Code’ is closed to new replies.