• Resolved fromvaldivia88

    (@fromvaldivia88)


    I’m using the Smoothstate library for transitions between pages, all right until I put the “Restaurant Reservations” plugin, which I can not start in the SmoothState onAfter method. What can I do to start the plugin when the page is updated in the transition.

    Example

    $(function(){
          'use strict';
            var options = {
              prefetch: true,
              pageCacheSize: 4,
              blacklist : '',
              development : false,
              cacheLength: 2,
                anchors: 'a',
              onBefore: function($container){
              },
              onStart: {
                duration:2500, // Duration of our animation
                render: function ($container) {
                  // Add your CSS animation reversing class
                  loaderaparece();
                  toTop();
    
                  $container.addClass('is-exiting');
    
                  // Restart your animation
                  smoothState.restartCSSAnimations();
                }
              },
              onReady: {
                duration: 1300,
                render: function ($container, $newContent) {
                  // Remove your CSS animation reversing class
                  $container.removeClass('is-exiting');
                  loaderOut();
    
                  // Inject the new content
                  $container.html($newContent);
                }
              },
              onAfter:
                function($container) {
                  destroyParallax();
                  parallaxImage();
                  overlayMenu();
                  parrallaxClass();
                  sliderMia();
                  mouseTarget();
                  initMap();
                  reservas();
              }
            },
            smoothState = $('#main').smoothState(options).data('smoothState');
        });
    
    function reservas(){
    tb_booking_form.init();
    }
Viewing 1 replies (of 1 total)
  • NateWr

    (@natewr)

    Hi @fromvaldivia88,

    I generally recommend avoiding any smooth page transitions features, and turning them off in any theme that includes them, because they lead to incompatibilities.

    I’m not sure if there’s really a way to do what you want short of editing my plugin. When the booking-form.js file is loaded, it will fire rtb_booking_form.init() on jQuery’s document loaded event.

    If that fires when the booking form isn’t actually on the page, it will cause a JavaScript error. So you may need to load a modified version of that file which doesn’t fire rtb_booking_form.init() until you decide it’s appropriate.

    That may lead to other issues if the event listeners aren’t de-registered when the booking form is removed. Building a site with no full-page refreshes is a very different way of engineering a site, and trying to shoe-horn plugins built for one technique into a different one is going to be an uphill battle. Sorry I can’t be more helpful.

Viewing 1 replies (of 1 total)

The topic ‘Plugin not working with page transitions’ is closed to new replies.