Monaca Onsen UI Discord Chat Github Repo

Problems in Drag & Drop while moving to Onsen 2



  • @Fran-Diox ah…ok, very clear. Thank you. This will work as we are going to switch off gesture on one specific page where drag and drop is required.

    Just one quick question (probably a last one on this :blush:). Unlike document body, gesture detector couldn’t be reactivated for splitter. I tried reactivating it by assigning new ons.GestureDetector(…) to variable name, document.querySelector(‘ons-splitter-side’), document.getElementById (…) but none of them worked. (demo updated)

    Once disabled, I couldn’t again get swipe menu activated. I saw in documentations that ons.GestureDetector has optional options parameter. Do we need to use any specific option in case of splitter?

    Regards,
    CNaik.


  • Onsen UI

    @CNaik Oh yes, I forgot about that, sorry. You need to pass the parent element as a parameter. Something like this:
    splitterSide._gestureDetector = new GestureDetector(splitterSide.parentElement, {dragMinDistance: 1});



  • @Fran-Diox unfortunately it didn’t solve the problem (demo updated). May be any other required options missing?

    One thing I noticed that for dispose and create statements, I had to use variable name specified in id attribute in HTML. Normally we use variable specified with var attribute. Which is not working in this case. I guess this might be very normal. But I noticed this for first time and hence bringing into your notice if it’s something new.

    Regards,
    CNaik.


  • Onsen UI

    @CNaik One more thing, it needs to refresh the swipeable attribute in order to listen for the events again. The easiest way is to remove it and set it again. Updated here: http://codepen.io/frankdiox/pen/RaQpQQ

    About using var attribute or not… var is only for Angular stuff. Here we are modifying the core so we need to use the real components. Normally you would need to do document.querySeletor('#splMenu'); to access the component. However, due to some hidden feature of HTML (not in Onsen), global variables are created for every ID so technically you can use splMenu with the same result. For example, you can access to <div id="myDiv"></div> with window.myDiv. This is quite error prone and I’d say it’s not recommended.



  • @Fran-Diox it’s working perfectly now. Thank you for your valuable input.

    We will avoid using global variables.

    Regards,
    CNaik.