Support » Plugin: Age Gate » How to implement delay on loading

  • Hi there,

    I’m using your plugin multisite with caching and the JS version fits my needs very well.
    Now basically a visitor lands on age age but I’d like some sort of delay before the disclaimer appears. Will it be possible to implement in future releases or with custom script?

    Thanks

Viewing 1 replies (of 1 total)
  • Plugin Author Phil

    (@philsbury)

    Hi @clairedelacroix,

    You can do that now with a bit of custom JS.

    Here’s a very quick example – could tweak the functions, to do some transitions, but you get the idea;

    
    jQuery(function () {
      jQuery(document).on('agegateshown', function () {
        // quick test to see if we should show AG
        var shouldShow = jQuery('body').hasClass('age-restriction');
        
        // Hide AG and remove it's body class
        jQuery('.age-gate-wrapper').hide();
        jQuery('body').removeClass('age-restriction');
    
        // if we want to show
        if (shouldShow) {
          setTimeout(function(){
            // Reshow stuff
            jQuery('.age-gate-wrapper').show();
            jQuery('body').addClass('age-restriction');
          }, 5000); // show after 5 seconds
        }
      });
    });
    

    Thanks
    Phil

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.