Logic Machine Forum
Swipe limited to some pages - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Visualization (https://forum.logicmachine.net/forumdisplay.php?fid=9)
+--- Thread: Swipe limited to some pages (/showthread.php?tid=3791)



Swipe limited to some pages - Mirco - 05.01.2022

Hi, it is possible to enable swipe into visu only for determinated pages?

I would like to do a think like this:
- 3 floor
- every floor have 3 pages
- when in one of the 3 pages of a floor switch between them and only them using swipe

is there a way?
Thanks and happy new year!


RE: Swipe limited to some pages - admin - 05.01.2022

You can override the swipe handler function and provide a list of allowed plan IDs where swap should work.
Add to Custom JavaScript:
Code:
$(function() {
  var fn = showPrevNextPlan;
  var allowed = [ 4, 6, 10 ]; // allowed plan IDs
  
  showPrevNextPlan = function(next) {
    if (allowed.indexOf(currentPlanId) >= 0) {
      fn(next);
    }
  };  
});



RE: Swipe limited to some pages - Mirco - 05.01.2022

It works partially: it allows to swipe to the next/previous page (that isn't in the var allowed)

with this script it isn't possible to do the same thing with all floors right?
Example:
floor 1, swipe only allowed between floor 1 pages (5, 6, 7)
floor 2, swipe only allowed between floor 2 pages (8, 9, 10)


RE: Swipe limited to some pages - admin - 05.01.2022

This will make swipe work only inside current level plans:
Code:
$(function() {
  showPrevNextPlan = function(next) {
    var el = $('#menu-plan-' + currentPlanId);
    var nel = next ? el.next() : el.prev();

    if (!nel.length || nel.hasClass('level')) {
      el = next ? el.prevUntil('.level') : el.nextUntil('.level');
      nel = $(el.get(-1));
    }

    nel.find('.a').click();
  };  
});



RE: Swipe limited to some pages - Mirco - 05.01.2022

Thanks! It works perfecly with mouse on my pc and ipad but with the touch it work only when i'm in the first floor that I displayed, after I change the floor it stop working on all floors.. I tried on safari and firefox and it's the same


RE: Swipe limited to some pages - Mirco - 10.01.2022

admin or someone can help me?


RE: Swipe limited to some pages - admin - 10.01.2022

Can you post a screenshot of your structure?


RE: Swipe limited to some pages - Mirco - 10.01.2022

Attached the screenshot

When into the floor P1 it works, when I switch to floor PT it stop to work even when I return to floor P1. This happen only with touch (ipad iphone and android) because if I use mouse on this devices it works correctly


RE: Swipe limited to some pages - admin - 10.01.2022

See if this helps:
Code:
$(function() {
  showPrevNextPlan = function(next) {
    var el = $('.nav-main .active');
    var nel = next ? el.next() : el.prev();

    if (!nel.length || nel.hasClass('level')) {
      el = next ? el.prevUntil('.level') : el.nextUntil('.level');
      nel = $(el.get(-1));
    }

    nel.find('.a').trigger('vclick');
  };  
});



RE: Swipe limited to some pages - admin - 10.01.2022

Are you sure the custom script is working? What you are describing is the default swipe action. If this happens on all platforms then check browser console (F12) for any errors.


RE: Swipe limited to some pages - Mirco - 10.01.2022

Sorry, yes it woks perfectly, a made a mistake deleting an istruction..