This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Swipe limited to some pages
#1
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!
Reply
#2
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);
    }
  };  
});
Reply
#3
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)
Reply
#4
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();
  };  
});
Reply
#5
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
Reply
#6
admin or someone can help me?
Reply
#7
Can you post a screenshot of your structure?
Reply
#8
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

Attached Files Thumbnail(s)
   
Reply
#9
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');
  };  
});
Reply
#10
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.
Reply
#11
Sorry, yes it woks perfectly, a made a mistake deleting an istruction..
Reply


Forum Jump: