Denis Denis - 6 months ago 33
jQuery Question

jQuery.mmenu dragOpen disable dragging at desktop

jQuery.mmenu uses Hammer.js for dragging, in the docs jQuery.mmenu says


Hammer.js enables dragging on touch and desktop devices. If you only want to enable dragging the menu open on touchscreens, use the $.mmenu.support.touch variable.


I definitely want to disable dragging for desktops and use it's behaviour only at mobile. It says i shoud use
$.mmenu.support.touch
to do so. But how to use it? I've tried all possible scenarios, used any type there, placed it before and after plugin initialisation, but without luck.

How to use
$.mmenu.support.touch
to disable opening menu by mouse dragging on desktops?

Answer

I was looking for an answer to this too and figured it out just now. This is my whole configuration.

$(document).ready(function(){
                    $("#mmenu-left").mmenu(
                        {
                            extensions: ["theme-dark"],
                            dragOpen: { open: ($.mmenu.support.touch?true:false) }
                        },
                        {
                            offCanvas: {
                                pageSelector: "#thepage"
                            }
                        }
                    );
            });

This is the part for that enables dragopen only on touch devices:

dragOpen: { open: ($.mmenu.support.touch?true:false) }