Can you open side menu with a swipe from left to right ? (Touchscreen)

Good morning / afternoon,

I'm using the dashboard on a touch screen, I would like to know if there's a simple way of opening the side menu with a swipe from left to right ? (I don't like the navigate between tabs with swipes)

I was going to try to do it with some ui_template node and some javascript, but I'm not sure if there's already a custom event listener to listen to swipes (I guess there's some because you can swipe between tabs)

Hi - no - currently it is swipe between tabs - or not.

You may try to play with this:
image

And with ui_template:

<script>
$("body").on("swipeleft",function( event ) {
    if($("md-sidenav").hasClass("md-locked-open")){
        $("md-sidenav").removeClass("md-locked-open")        
    }
})
$("body").on("swiperight",function( event ) {
    if($("md-sidenav").hasClass("md-locked-open") == false){
        $("md-sidenav").addClass("md-locked-open")
    }
})
</script>

The ui_template probably must exist in all tabs ... and I can't give any guarantees :smiley:

Actually I was in there looking at fixing something else so have added it as an option for next release :wink:
Now pushed to master

3 Likes

Thank you @hotNipi for your answer, I'll try it out when I have time and I'll get back to you to let you know if it's working !

Ok so,

I did some testing on my side your solution works fine but I tweaked it a bit to fit my needs,

  • I disabled the "Always show side menu" and went for "Click to show side menu", because it caused me some troubles, the groups would not re-arrange properly when closing the side nav
  • I added to the script the part to remove the class so that when I change tab, the tab close automatically (I just copied and past the part where you remove the class but without the swipe event detection)

Would you know by any chance how to add the animation to the opening ? :grin:

Thank you for your amazing solution by the way !

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.