SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    side menu closing when tap-ing on menu item

    Hi guys!

    I am working on a website and i try to make the side menu (sidr) close when i access a menu item. Usually after i click/tap on one, the menu still stays and i need to close it using the menu button again.

    I succeeded to make it work on desktops, but i dont know how to make it on mobile.

    Could anyone help me?

    Here is the code i used to make it work on desktop:
    Code:
    <script src="js/jquery.sidr.js"></script>
    <script>
    $(document).ready(function() {
    $('#simple-menu').sidr();
    });
    </script>
    
    <script src="js/jquery.touchswipe.js"></script>
     
    <script>
    $(document).click(function () {
    $.sidr('close');
    });
    
    $(document).keyup(function ( e ) {
    var key = e.keyCode || e.which;
    if ( key === 27 ) {
    $.sidr('close');
    }
    });
    
    </script>

  2. #2
    SitePoint Member
    Join Date
    Mar 2014
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've received an idea that i should change my code to:

    $(document).on('click touchstart', function () {
    $.sidr('close');
    });

    for desktop works fine, but on mobile the menu slides out and than directly slides in again automatically without that i even touch something.




    if i use just:

    <script>
    $(document).on('touchstart', function () {
    $.sidr('close');
    });

    than the menu works good (stays open and when i touch it slides in) but like this it doesnt open a page...


    anyone have an idea?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •